Skip to content
Browse files

Revisions: move the call to _wp_upgrade_revisions_of_post() to edit-f…

…orm-advanced.php, in the code block checking whether we should show the revisions postbox. See #16215

git-svn-id: http://core.svn.wordpress.org/trunk@23929 1a063a9b-81f0-0310-95a4-ce76da25c4cd
  • Loading branch information...
1 parent 33dd4b3 commit 9fe85b154e4137e1635a20672260f73f88d64502 Andrew Ozz committed
Showing with 16 additions and 28 deletions.
  1. +11 −3 wp-admin/edit-form-advanced.php
  2. +0 −3 wp-admin/post.php
  3. +5 −22 wp-includes/revision.php
View
14 wp-admin/edit-form-advanced.php
@@ -227,9 +227,17 @@
add_meta_box('authordiv', __('Author'), 'post_author_meta_box', null, 'normal', 'core');
}
-// We should aim to show the revisions metabox only when there are revisions.
-if ( post_type_supports($post_type, 'revisions') && 'auto-draft' != $post->post_status && count( wp_get_post_revisions( $post_ID ) ) > 1 )
- add_meta_box('revisionsdiv', __('Revisions'), 'post_revisions_meta_box', null, 'normal', 'core');
+if ( post_type_supports($post_type, 'revisions') && 'auto-draft' != $post->post_status ) {
+ $revisions = wp_get_post_revisions( $post_ID );
+
+ // Check if the revisions have been upgraded
+ if ( ! empty( $revisions ) && _wp_get_post_revision_version( reset( $revisions ) ) < 1 )
+ _wp_upgrade_revisions_of_post( $post, $revisions );
+
+ // We should aim to show the revisions metabox only when there are revisions.
+ if ( count( $revisions ) > 1 )
+ add_meta_box('revisionsdiv', __('Revisions'), 'post_revisions_meta_box', null, 'normal', 'core');
+}
do_action('add_meta_boxes', $post_type, $post);
do_action('add_meta_boxes_' . $post_type, $post);
View
3 wp-admin/post.php
@@ -154,9 +154,6 @@ function redirect_post($post_id = '') {
exit();
}
- //upgrade any old bad revision data (#16215)
- _wp_upgrade_revisions_of_post( $p );
-
$post_type = $post->post_type;
if ( 'post' == $post_type ) {
$parent_file = "edit.php";
View
27 wp-includes/revision.php
@@ -586,38 +586,21 @@ function _wp_get_post_revision_version( $revision ) {
}
/**
- * Upgrade the data
+ * Upgrade the revisions author, add the current post as a revision and set the revisions version to 1
*
* @package WordPress
* @subpackage Post_Revisions
* @since 3.6.0
*
- * @uses get_post()
- * @uses post_type_supports()
* @uses wp_get_post_revisions()
*
- * @param int|object $post_id Post ID or post object
- * @return true if success, false if problems
+ * @param object $post Post object
+ * @param array $revisions Current revisions of the post
+ * @return bool true if the revisions were upgraded, false if problems
*/
-function _wp_upgrade_revisions_of_post( $post ) {
+function _wp_upgrade_revisions_of_post( $post, $revisions ) {
global $wpdb;
- $post = get_post( $post );
- if ( ! $post )
- return false;
-
- if ( ! post_type_supports( $post->post_type, 'revisions' ) )
- return false;
-
- $revisions = wp_get_post_revisions( $post->ID ); // array( 'order' => 'DESC', 'orderby' => 'date' ); // Always work from most recent to oldest
-
- if ( ! $first = reset( $revisions ) )
- return true;
-
- // Check if the revisions have already been updated
- if ( preg_match( '/^\d+-(?:autosave|revision)-v\d+$/', $first->post_name ) )
- return true;
-
// Add post option exclusively
$lock = "revision-upgrade-{$post->ID}";
$now = time();

0 comments on commit 9fe85b1

Please sign in to comment.
Something went wrong with that request. Please try again.