mirror of
https://github.com/WordPress/WordPress.git
synced 2025-01-03 06:57:35 +01:00
Revisions: move the call to _wp_upgrade_revisions_of_post() to edit-form-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
This commit is contained in:
parent
33dd4b3d69
commit
9fe85b154e
@ -227,9 +227,17 @@ if ( post_type_supports($post_type, 'author') ) {
|
||||
add_meta_box('authordiv', __('Author'), 'post_author_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 ( post_type_supports($post_type, 'revisions') && 'auto-draft' != $post->post_status && count( wp_get_post_revisions( $post_ID ) ) > 1 )
|
||||
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);
|
||||
|
@ -154,9 +154,6 @@ case 'edit':
|
||||
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";
|
||||
|
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user