<!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" />
<title>[23735] trunk: Create one autosave per user rather than a single autosave for all users.</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { 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 { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg > ul, #logmsg > ol { margin-left: 0; margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#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>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://core.trac.wordpress.org/changeset/23735">23735</a></dd>
<dt>Author</dt> <dd>azaozz</dd>
<dt>Date</dt> <dd>2013-03-16 21:15:43 +0000 (Sat, 16 Mar 2013)</dd>
</dl>

<h3>Log Message</h3>
<pre>Create one autosave per user rather than a single autosave for all users. Remove unused code from autosave.js and wp_ajax_autosave(). See <a href="http://core.trac.wordpress.org/ticket/23665">#23665</a>.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadminincludesajaxactionsphp">trunk/wp-admin/includes/ajax-actions.php</a></li>
<li><a href="#trunkwpadminincludespostphp">trunk/wp-admin/includes/post.php</a></li>
<li><a href="#trunkwpincludesjsautosavejs">trunk/wp-includes/js/autosave.js</a></li>
<li><a href="#trunkwpincludesrevisionphp">trunk/wp-includes/revision.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadminincludesajaxactionsphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/ajax-actions.php (23734 => 23735)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/ajax-actions.php        2013-03-16 20:58:37 UTC (rev 23734)
+++ trunk/wp-admin/includes/ajax-actions.php        2013-03-16 21:15:43 UTC (rev 23735)
</span><span class="lines">@@ -1043,15 +1043,12 @@
</span><span class="cx">                 unset($_POST['post_category']);
</span><span class="cx"> 
</span><span class="cx">         $do_autosave = (bool) $_POST['autosave'];
</span><del>-        $do_lock = true;
</del><span class="cx">         $data = '';
</span><span class="cx">         $supplemental = array();
</span><span class="cx">         $id = $revision_id = 0;
</span><span class="cx"> 
</span><del>-        /* translators: draft saved date format, see http://php.net/date */
-        $draft_saved_date_format = __('g:i:s a');
-        /* translators: %s: date and time */
-        $message = sprintf( __('Draft saved at %s.'), date_i18n( $draft_saved_date_format ) );
</del><ins>+        if ( ! $user_id = get_current_user_id() )
+                wp_die('-1');
</ins><span class="cx"> 
</span><span class="cx">         $post_id = (int) $_POST['post_id'];
</span><span class="cx">         $_POST['ID'] = $_POST['post_ID'] = $post_id;
</span><span class="lines">@@ -1059,17 +1056,6 @@
</span><span class="cx">         if ( 'auto-draft' == $post-&gt;post_status )
</span><span class="cx">                 $_POST['post_status'] = 'draft';
</span><span class="cx"> 
</span><del>-        if ( $last = wp_check_post_lock( $post-&gt;ID ) ) {
-                // This will change after we have per-user autosaves
-                $do_autosave = $do_lock = false;
-
-                $last_user = get_userdata( $last );
-                $last_user_name = $last_user ? $last_user-&gt;display_name : __( 'Someone' );
-                $data = __( 'Autosave disabled.' );
-
-                $supplemental['disable_autosave'] = 'disable';
-        }
-
</del><span class="cx">         if ( 'page' == $post-&gt;post_type ) {
</span><span class="cx">                 if ( !current_user_can('edit_page', $post-&gt;ID) )
</span><span class="cx">                         wp_die( __( 'You are not allowed to edit this page.' ) );
</span><span class="lines">@@ -1079,17 +1065,28 @@
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         if ( $do_autosave ) {
</span><del>-                // Drafts and auto-drafts are just overwritten by autosave
-                if ( 'auto-draft' == $post-&gt;post_status || 'draft' == $post-&gt;post_status ) {
</del><ins>+                // Drafts and auto-drafts are just overwritten by autosave for the same user
+                if ( $user_id == $post-&gt;post_author &amp;&amp; ( 'auto-draft' == $post-&gt;post_status || 'draft' == $post-&gt;post_status ) ) {
</ins><span class="cx">                         $id = edit_post();
</span><del>-                } else { // Non drafts are not overwritten. The autosave is stored in a special post revision.
</del><ins>+                } else { // Non drafts are not overwritten. The autosave is stored in a special post revision for each user.
</ins><span class="cx">                         $revision_id = wp_create_post_autosave( $post-&gt;ID );
</span><span class="cx">                         if ( is_wp_error($revision_id) )
</span><span class="cx">                                 $id = $revision_id;
</span><span class="cx">                         else
</span><span class="cx">                                 $id = $post-&gt;ID;
</span><span class="cx">                 }
</span><del>-                $data = $message;
</del><ins>+
+                if ( is_wp_error($id) ) {
+                        // is_wp_error($id) overwrites $data in WP_Ajax_Response but no point in doing wp_create_nonce('update-post_' . $id) below
+                        // todo: Needs review. The errors generated in WP_Ajax_Response and parsed with wpAjax.parseAjaxResponse() haven't been used for many years.
+                        $data = $id;
+                        $id = 0;
+                } else {
+                        /* translators: draft saved date format, see http://php.net/date */
+                        $draft_saved_date_format = __('g:i:s a');
+                        /* translators: %s: date and time */
+                        $data = sprintf( __('Draft saved at %s.'), date_i18n( $draft_saved_date_format ) );
+                }
</ins><span class="cx">         } else {
</span><span class="cx">                 if ( ! empty( $_POST['auto_draft'] ) )
</span><span class="cx">                         $id = 0; // This tells us it didn't actually save
</span><span class="lines">@@ -1103,12 +1100,8 @@
</span><span class="cx">                 $supplemental['replace-samplepermalinknonce'] = wp_create_nonce('samplepermalink');
</span><span class="cx">                 $supplemental['replace-closedpostboxesnonce'] = wp_create_nonce('closedpostboxes');
</span><span class="cx">                 $supplemental['replace-_ajax_linking_nonce'] = wp_create_nonce( 'internal-linking' );
</span><del>-                if ( $id ) {
-                        if ( $_POST['post_type'] == 'post' )
-                                $supplemental['replace-_wpnonce'] = wp_create_nonce('update-post_' . $id);
-                        elseif ( $_POST['post_type'] == 'page' )
-                                $supplemental['replace-_wpnonce'] = wp_create_nonce('update-page_' . $id);
-                }
</del><ins>+                if ( $id )
+                        $supplemental['replace-_wpnonce'] = wp_create_nonce('update-post_' . $id);
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         $x = new WP_Ajax_Response( array(
</span></span></pre></div>
<a id="trunkwpadminincludespostphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/post.php (23734 => 23735)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/post.php        2013-03-16 20:58:37 UTC (rev 23734)
+++ trunk/wp-admin/includes/post.php        2013-03-16 21:15:43 UTC (rev 23735)
</span><span class="lines">@@ -1280,11 +1280,13 @@
</span><span class="cx">         if ( is_wp_error( $translated ) )
</span><span class="cx">                 return $translated;
</span><span class="cx"> 
</span><del>-        // Only store one autosave. If there is already an autosave, overwrite it.
-        if ( $old_autosave = wp_get_post_autosave( $post_id ) ) {
</del><ins>+        $post_author = get_current_user_id();
+
+        // Store one autosave per author. If there is already an autosave, overwrite it.
+        if ( $old_autosave = wp_get_post_autosave( $post_id, $post_author ) ) {
</ins><span class="cx">                 $new_autosave = _wp_post_revision_fields( $_POST, true );
</span><span class="cx">                 $new_autosave['ID'] = $old_autosave-&gt;ID;
</span><del>-                $new_autosave['post_author'] = get_current_user_id();
</del><ins>+                $new_autosave['post_author'] = $post_author;
</ins><span class="cx">                 return wp_update_post( $new_autosave );
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="lines">@@ -1339,7 +1341,8 @@
</span><span class="cx">                         wp_die(__('You are not allowed to edit this post.'));
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        if ( 'draft' == $post-&gt;post_status ) {
</del><ins>+        $user_id = get_current_user_id();
+        if ( 'draft' == $post-&gt;post_status &amp;&amp; $user_id == $post-&gt;post_author ) {
</ins><span class="cx">                 $id = edit_post();
</span><span class="cx">         } else { // Non drafts are not overwritten. The autosave is stored in a special post revision.
</span><span class="cx">                 $id = wp_create_post_autosave( $post-&gt;ID );
</span><span class="lines">@@ -1350,7 +1353,7 @@
</span><span class="cx">         if ( is_wp_error($id) )
</span><span class="cx">                 wp_die( $id-&gt;get_error_message() );
</span><span class="cx"> 
</span><del>-        if ( $_POST['post_status'] == 'draft'  ) {
</del><ins>+        if ( $_POST['post_status'] == 'draft' &amp;&amp; $user_id == $post-&gt;post_author ) {
</ins><span class="cx">                 $url = add_query_arg( 'preview', 'true', get_permalink($id) );
</span><span class="cx">         } else {
</span><span class="cx">                 $nonce = wp_create_nonce('post_preview_' . $id);
</span></span></pre></div>
<a id="trunkwpincludesjsautosavejs"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/js/autosave.js (23734 => 23735)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/js/autosave.js        2013-03-16 20:58:37 UTC (rev 23734)
+++ trunk/wp-includes/js/autosave.js        2013-03-16 21:15:43 UTC (rev 23735)
</span><span class="lines">@@ -1,4 +1,4 @@
</span><del>-var autosave, autosaveLast = '', autosavePeriodical, autosaveOldMessage = '', autosaveDelayPreview = false, notSaved = true, blockSave = false, fullscreen, autosaveLockRelease = true;
</del><ins>+var autosave, autosaveLast = '', autosavePeriodical, autosaveDelayPreview = false, notSaved = true, blockSave = false, fullscreen, autosaveLockRelease = true;
</ins><span class="cx"> 
</span><span class="cx"> jQuery(document).ready( function($) {
</span><span class="cx"> 
</span><span class="lines">@@ -130,49 +130,29 @@
</span><span class="cx">         }
</span><span class="cx"> });
</span><span class="cx"> 
</span><del>-function autosave_parse_response(response) {
-        var res = wpAjax.parseAjaxResponse(response, 'autosave'), message = '', postID, sup;
</del><ins>+function autosave_parse_response( response ) {
+        var res = wpAjax.parseAjaxResponse(response, 'autosave'), post_id, sup;
</ins><span class="cx"> 
</span><span class="cx">         if ( res &amp;&amp; res.responses &amp;&amp; res.responses.length ) {
</span><del>-                message = res.responses[0].data; // The saved message or error.
-                // someone else is editing: disable autosave, set errors
</del><span class="cx">                 if ( res.responses[0].supplemental ) {
</span><span class="cx">                         sup = res.responses[0].supplemental;
</span><del>-                        if ( 'disable' == sup['disable_autosave'] ) {
-                                autosave = function() {};
-                                autosaveLockRelease = false;
-                                res = { errors: true };
-                        }
</del><span class="cx"> 
</span><del>-                        if ( sup['active-post-lock'] ) {
-                                jQuery('#active_post_lock').val( sup['active-post-lock'] );
-                        }
-
-                        if ( sup['alert'] ) {
-                                jQuery('#autosave-alert').remove();
-                                jQuery('#titlediv').after('&lt;div id=&quot;autosave-alert&quot; class=&quot;error below-h2&quot;&gt;&lt;p&gt;' + sup['alert'] + '&lt;/p&gt;&lt;/div&gt;');
-                        }
-
-                        jQuery.each(sup, function(selector, value) {
-                                if ( selector.match(/^replace-/) ) {
-                                        jQuery('#'+selector.replace('replace-', '')).val(value);
-                                }
</del><ins>+                        jQuery.each( sup, function( selector, value ) {
+                                if ( selector.match(/^replace-/) )
+                                        jQuery( '#' + selector.replace('replace-', '') ).val( value );
</ins><span class="cx">                         });
</span><span class="cx">                 }
</span><span class="cx"> 
</span><del>-                // if no errors: add slug UI
</del><ins>+                // if no errors: add slug UI and update autosave-message
</ins><span class="cx">                 if ( !res.errors ) {
</span><del>-                        postID = parseInt( res.responses[0].id, 10 );
-                        if ( !isNaN(postID) &amp;&amp; postID &gt; 0 ) {
-                                autosave_update_slug(postID);
-                        }
</del><ins>+                        if ( post_id = parseInt( res.responses[0].id, 10 ) )
+                                autosave_update_slug( post_id );
+
+                        if ( res.responses[0].data ) // update autosave message
+                                jQuery('.autosave-message').text( res.responses[0].data );
</ins><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        if ( message ) { // update autosave message
-                jQuery('.autosave-message').html(message);
-        } else if ( autosaveOldMessage &amp;&amp; res ) {
-                jQuery('.autosave-message').html( autosaveOldMessage );
-        }
</del><ins>+
</ins><span class="cx">         return res;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -186,16 +166,19 @@
</span><span class="cx"> // called when autosaving new post
</span><span class="cx"> function autosave_saved_new(response) {
</span><span class="cx">         blockSave = false;
</span><del>-        var res = autosave_parse_response(response), postID;
</del><ins>+        var res = autosave_parse_response(response), post_id;
</ins><span class="cx"> 
</span><span class="cx">         if ( res &amp;&amp; res.responses.length &amp;&amp; !res.errors ) {
</span><span class="cx">                 // An ID is sent only for real auto-saves, not for autosave=0 &quot;keepalive&quot; saves
</span><del>-                postID = parseInt( res.responses[0].id, 10 );
-                if ( !isNaN(postID) &amp;&amp; postID &gt; 0 ) {
</del><ins>+                post_id = parseInt( res.responses[0].id, 10 );
+
+                if ( post_id ) {
</ins><span class="cx">                         notSaved = false;
</span><span class="cx">                         jQuery('#auto_draft').val('0'); // No longer an auto-draft
</span><span class="cx">                 }
</span><ins>+
</ins><span class="cx">                 autosave_enable_buttons();
</span><ins>+
</ins><span class="cx">                 if ( autosaveDelayPreview ) {
</span><span class="cx">                         autosaveDelayPreview = false;
</span><span class="cx">                         doPreview();
</span><span class="lines">@@ -286,7 +269,6 @@
</span><span class="cx">                 successCallback = autosave_saved; // pre-existing post
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        autosaveOldMessage = jQuery('#autosave').html();
</del><span class="cx">         jQuery.ajax({
</span><span class="cx">                 data: post_data,
</span><span class="cx">                 beforeSend: doAutoSave ? autosave_loading : null,
</span></span></pre></div>
<a id="trunkwpincludesrevisionphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/revision.php (23734 => 23735)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/revision.php        2013-03-16 20:58:37 UTC (rev 23734)
+++ trunk/wp-includes/revision.php        2013-03-16 21:15:43 UTC (rev 23735)
</span><span class="lines">@@ -135,54 +135,35 @@
</span><span class="cx">  * Retrieve the autosaved data of the specified post.
</span><span class="cx">  *
</span><span class="cx">  * Returns a post object containing the information that was autosaved for the
</span><del>- * specified post.
</del><ins>+ * specified post. If the optional $user_id is passed, returns the autosave for that user
+ * otherwise returns the latest autosave.
</ins><span class="cx">  *
</span><span class="cx">  * @package WordPress
</span><span class="cx">  * @subpackage Post_Revisions
</span><span class="cx">  * @since 2.6.0
</span><del>- *
</del><ins>+ * @uses wp_get_post_revisions()
+ *  
</ins><span class="cx">  * @param int $post_id The post ID.
</span><ins>+ * @param int $user_id optional The post author ID.
</ins><span class="cx">  * @return object|bool The autosaved data or false on failure or when no autosave exists.
</span><span class="cx">  */
</span><del>-function wp_get_post_autosave( $post_id ) {
</del><ins>+function wp_get_post_autosave( $post_id, $user_id = 0 ) {
+        $revisions = wp_get_post_revisions($post_id);
</ins><span class="cx"> 
</span><del>-        if ( !$post = get_post( $post_id ) )
-                return false;
</del><ins>+        foreach ( $revisions as $revision ) {
+                if ( false !== strpos( $revision-&gt;post_name, &quot;{$post_id}-autosave&quot; ) ) {
+                        if ( $user_id &amp;&amp; $user_id != $revision-&gt;post_author )
+                                continue;
</ins><span class="cx"> 
</span><del>-        $q = array(
-                'name' =&gt; &quot;{$post-&gt;ID}-autosave&quot;,
-                'post_parent' =&gt; $post-&gt;ID,
-                'post_type' =&gt; 'revision',
-                'post_status' =&gt; 'inherit'
-        );
</del><ins>+                        return $revision;
+                        break;
+                }
+        }
</ins><span class="cx"> 
</span><del>-        // Use WP_Query so that the result gets cached
-        $autosave_query = new WP_Query;
-
-        add_action( 'parse_query', '_wp_get_post_autosave_hack' );
-        $autosave = $autosave_query-&gt;query( $q );
-        remove_action( 'parse_query', '_wp_get_post_autosave_hack' );
-
-        if ( $autosave &amp;&amp; is_array($autosave) &amp;&amp; is_object($autosave[0]) )
-                return $autosave[0];
-
</del><span class="cx">         return false;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /**
</span><del>- * Internally used to hack WP_Query into submission.
- *
- * @package WordPress
- * @subpackage Post_Revisions
- * @since 2.6.0
- *
- * @param object $query WP_Query object
- */
-function _wp_get_post_autosave_hack( $query ) {
-        $query-&gt;is_single = false;
-}
-
-/**
</del><span class="cx">  * Determines if the specified post is a revision.
</span><span class="cx">  *
</span><span class="cx">  * @package WordPress
</span><span class="lines">@@ -195,6 +176,7 @@
</span><span class="cx"> function wp_is_post_revision( $post ) {
</span><span class="cx">         if ( !$post = wp_get_post_revision( $post ) )
</span><span class="cx">                 return false;
</span><ins>+
</ins><span class="cx">         return (int) $post-&gt;post_parent;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -211,9 +193,11 @@
</span><span class="cx"> function wp_is_post_autosave( $post ) {
</span><span class="cx">         if ( !$post = wp_get_post_revision( $post ) )
</span><span class="cx">                 return false;
</span><del>-        if ( &quot;{$post-&gt;post_parent}-autosave&quot; !== $post-&gt;post_name )
-                return false;
-        return (int) $post-&gt;post_parent;
</del><ins>+
+        if ( false !== strpos( $post-&gt;post_name, &quot;{$post-&gt;post_parent}-autosave&quot; ) )
+                return (int) $post-&gt;post_parent;
+
+        return false;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /**
</span><span class="lines">@@ -234,6 +218,7 @@
</span><span class="cx">                 $post = get_object_vars( $post );
</span><span class="cx">         elseif ( !is_array($post) )
</span><span class="cx">                 $post = get_post($post, ARRAY_A);
</span><ins>+
</ins><span class="cx">         if ( !$post || empty($post['ID']) )
</span><span class="cx">                 return;
</span><span class="cx"> 
</span><span class="lines">@@ -249,6 +234,7 @@
</span><span class="cx"> 
</span><span class="cx">         if ( $revision_id )
</span><span class="cx">                 do_action( '_wp_put_post_revision', $revision_id );
</span><ins>+
</ins><span class="cx">         return $revision_id;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -312,8 +298,9 @@
</span><span class="cx">                 $fields = array_keys( _wp_post_revision_fields() );
</span><span class="cx"> 
</span><span class="cx">         $update = array();
</span><del>-        foreach( array_intersect( array_keys( $revision ), $fields ) as $field )
</del><ins>+        foreach( array_intersect( array_keys( $revision ), $fields ) as $field ) {
</ins><span class="cx">                 $update[$field] = $revision[$field];
</span><ins>+        }
</ins><span class="cx"> 
</span><span class="cx">         if ( !$update )
</span><span class="cx">                 return false;
</span><span class="lines">@@ -374,8 +361,6 @@
</span><span class="cx">  * @return array empty if no revisions
</span><span class="cx">  */
</span><span class="cx"> function wp_get_post_revisions( $post_id = 0, $args = null ) {
</span><del>-        if ( ! WP_POST_REVISIONS )
-                return array();
</del><span class="cx">         if ( ( !$post = get_post( $post_id ) ) || empty( $post-&gt;ID ) )
</span><span class="cx">                 return array();
</span><span class="cx"> 
</span><span class="lines">@@ -385,6 +370,7 @@
</span><span class="cx"> 
</span><span class="cx">         if ( !$revisions = get_children( $args ) )
</span><span class="cx">                 return array();
</span><ins>+
</ins><span class="cx">         return $revisions;
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>