Make WordPress Core

Ticket #16215: 16215-16.patch

File 16215-16.patch, 3.1 KB (added by azaozz, 12 years ago)
  • wp-admin/edit-form-advanced.php

     
    227227                add_meta_box('authordiv', __('Author'), 'post_author_meta_box', null, 'normal', 'core');
    228228}
    229229
    230 // We should aim to show the revisions metabox only when there are revisions.
    231 if ( post_type_supports($post_type, 'revisions') && 'auto-draft' != $post->post_status && count( wp_get_post_revisions( $post_ID ) ) > 1 )
    232         add_meta_box('revisionsdiv', __('Revisions'), 'post_revisions_meta_box', null, 'normal', 'core');
     230if ( post_type_supports($post_type, 'revisions') && 'auto-draft' != $post->post_status ) {
     231        $revisions = wp_get_post_revisions( $post_ID );
    233232
     233        // Check if the revisions have been upgraded
     234        if ( ! empty( $revisions ) && _wp_get_post_revision_version( reset( $revisions ) ) < 1 )
     235                _wp_upgrade_revisions_of_post( $post, $revisions );
     236
     237        // We should aim to show the revisions metabox only when there are revisions.
     238        if ( count( $revisions ) > 1 )
     239                add_meta_box('revisionsdiv', __('Revisions'), 'post_revisions_meta_box', null, 'normal', 'core');
     240}
     241
    234242do_action('add_meta_boxes', $post_type, $post);
    235243do_action('add_meta_boxes_' . $post_type, $post);
    236244
  • wp-admin/post.php

     
    154154                exit();
    155155        }
    156156
    157         //upgrade any old bad revision data (#16215)
    158         _wp_upgrade_revisions_of_post( $p );
    159 
    160157        $post_type = $post->post_type;
    161158        if ( 'post' == $post_type ) {
    162159                $parent_file = "edit.php";
  • wp-includes/revision.php

     
    554554}
    555555
    556556/**
    557  * Upgrade the data
     557 * Upgrade the revisions author, add the current post as a revision and set the revisions version to 1
    558558 *
    559559 * @package WordPress
    560560 * @subpackage Post_Revisions
    561561 * @since 3.6.0
    562562 *
    563  * @uses get_post()
    564  * @uses post_type_supports()
    565563 * @uses wp_get_post_revisions()
    566564 *
    567  * @param int|object $post_id Post ID or post object
    568  * @return true if success, false if problems
     565 * @param object Post object
     566 * @return bool true if the revisions were upgraded, false if problems
    569567 */
    570 function _wp_upgrade_revisions_of_post( $post ) {
     568function _wp_upgrade_revisions_of_post( $post, $revisions ) {
    571569        global $wpdb;
    572570
    573         $post = get_post( $post );
    574         if ( ! $post )
    575                 return false;
    576 
    577         if ( ! post_type_supports( $post->post_type, 'revisions' ) )
    578                 return false;
    579 
    580         $revisions = wp_get_post_revisions( $post->ID ); // array( 'order' => 'DESC', 'orderby' => 'date' ); // Always work from most recent to oldest
    581 
    582         if ( ! $first = reset( $revisions ) )
    583                 return true;
    584 
    585         // Check if the revisions have already been updated
    586         if ( preg_match( '/^\d+-(?:autosave|revision)-v\d+$/', $first->post_name ) )
    587                 return true;
    588 
    589571        // Add post option exclusively
    590572        $lock = "revision-upgrade-{$post->ID}";
    591573        $now = time();