From 2407b26f698ef16173b6672f9a729bef4c2af8b3 Mon Sep 17 00:00:00 2001 From: Andrew Ozz Date: Thu, 18 Apr 2013 04:43:59 +0000 Subject: [PATCH] Revisions: when upgrading the revision author don't add a copy of the post as latest revision when some of the revisions are already at v1. See #16215 git-svn-id: http://core.svn.wordpress.org/trunk@24025 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/revision.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/wp-includes/revision.php b/wp-includes/revision.php index b28affa01c..439f81ea74 100644 --- a/wp-includes/revision.php +++ b/wp-includes/revision.php @@ -627,6 +627,7 @@ function _wp_upgrade_revisions_of_post( $post, $revisions ) { update_option( $lock, $now ); reset( $revisions ); + $add_last = true; do { $this_revision = current( $revisions ); @@ -638,9 +639,12 @@ function _wp_upgrade_revisions_of_post( $post, $revisions ) { if ( false === $this_revision_version ) continue; - // 1 is the latest revision version, so we're already up to date - if ( 0 < $this_revision_version ) + // 1 is the latest revision version, so we're already up to date. + // No need to add a copy of the post as latest revision. + if ( 0 < $this_revision_version ) { + $add_last = false; continue; + } // Always update the revision version $update = array( @@ -669,7 +673,9 @@ function _wp_upgrade_revisions_of_post( $post, $revisions ) { delete_option( $lock ); // Add a copy of the post as latest revision. - wp_save_post_revision( $post->ID ); + if ( $add_last ) + wp_save_post_revision( $post->ID ); + return true; }