<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre, #msg p { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; }
#msg ul { overflow: auto; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<title>[11750] trunk/wp-includes: Trash status update, see #4529</title>
</head>
<body>
<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/11750">11750</a></dd>
<dt>Author</dt> <dd>azaozz</dd>
<dt>Date</dt> <dd>2009-07-30 14:55:07 +0000 (Thu, 30 Jul 2009)</dd>
</dl>
<h3>Log Message</h3>
<pre>Trash status update, see <a href="http://trac.wordpress.org/ticket/4529">#4529</a></pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpincludesfunctionsphp">trunk/wp-includes/functions.php</a></li>
<li><a href="#trunkwpincludespostphp">trunk/wp-includes/post.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpincludesfunctionsphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/functions.php (11749 => 11750)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/functions.php        2009-07-30 13:39:34 UTC (rev 11749)
+++ trunk/wp-includes/functions.php        2009-07-30 14:55:07 UTC (rev 11750)
</span><span class="lines">@@ -3352,18 +3352,18 @@
</span><span class="cx">
</span><span class="cx">         $delete_timestamp = time() - (60*60*24*EMPTY_TRASH_DAYS);
</span><span class="cx">
</span><del>-        foreach ( $trash_meta['comments'] as $id => $meta ) {
</del><ins>+        foreach ( (array) $trash_meta['comments'] as $id => $meta ) {
</ins><span class="cx">                 if ( $meta['time'] < $delete_timestamp ) {
</span><span class="cx">                         wp_delete_comment($id);
</span><span class="cx">                         unset($trash_meta['comments'][$id]);
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        foreach ( $trash_meta['posts'] as $id => $meta ) {
</del><ins>+        foreach ( (array) $trash_meta['posts'] as $id => $meta ) {
</ins><span class="cx">                 if ( $meta['time'] < $delete_timestamp ) {
</span><span class="cx">                         wp_delete_post($id);
</span><del>-                        unset($to_delete['posts'][$id]);
</del><ins>+                        unset($trash_meta['posts'][$id]);
</ins><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        update_option('wp_scheduled_delete', $to_delete);
</del><ins>+        update_option('wp_trash_meta', $trash_meta);
</ins><span class="cx"> }
</span></span></pre></div>
<a id="trunkwpincludespostphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/post.php (11749 => 11750)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/post.php        2009-07-30 13:39:34 UTC (rev 11749)
+++ trunk/wp-includes/post.php        2009-07-30 14:55:07 UTC (rev 11750)
</span><span class="lines">@@ -1249,7 +1249,7 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /**
</span><del>- * Removes a post or page from the Trash
</del><ins>+ * Restores a post or page from the Trash
</ins><span class="cx"> *
</span><span class="cx"> * @since 2.9.0
</span><span class="cx"> * @uses do_action() on 'untrash_post' before undeletion
</span><span class="lines">@@ -1259,22 +1259,22 @@
</span><span class="cx"> * @return mixed False on failure
</span><span class="cx"> */
</span><span class="cx"> function wp_untrash_post($postid = 0) {
</span><del>-        if (!$post = wp_get_single_post($postid, ARRAY_A))
</del><ins>+        if ( !$post = wp_get_single_post($postid, ARRAY_A) )
</ins><span class="cx">                 return $post;
</span><span class="cx">
</span><span class="cx">         do_action('untrash_post', $postid);
</span><del>-        
</del><ins>+
</ins><span class="cx">         $post['post_status'] = 'draft';
</span><del>-        
</del><ins>+
</ins><span class="cx">         $trash_meta = get_option('wp_trash_meta');
</span><del>-        if (is_array($trash_meta) && isset($trash_meta['posts'][$postid])) {
</del><ins>+        if ( is_array($trash_meta) && isset($trash_meta['posts'][$postid]) ) {
</ins><span class="cx">                 $post['post_status'] = $trash_meta['posts'][$postid]['status'];
</span><span class="cx">                 unset($trash_meta['posts'][$postid]);
</span><span class="cx">                 update_option('wp_trash_meta', $trash_meta);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         wp_insert_post($post);
</span><del>-        
</del><ins>+
</ins><span class="cx">         do_action('untrashed_post', $postid);
</span><span class="cx">
</span><span class="cx">         return $post;
</span><span class="lines">@@ -2662,7 +2662,7 @@
</span><span class="cx">
</span><span class="cx">         if ( 'attachment' != $post->post_type )
</span><span class="cx">                 return false;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if ( 'trash' != $post->post_status )
</span><span class="cx">                 return wp_trash_post($postid);
</span><span class="cx">
</span></span></pre>
</div>
</div>
</body>
</html>