WordPress.org

Make WordPress Core

Changeset 23929


Ignore:
Timestamp:
04/06/2013 11:43:05 PM (6 years ago)
Author:
azaozz
Message:

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

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/edit-form-advanced.php

    r23886 r23929  
    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 );
     232
     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}
    233241
    234242do_action('add_meta_boxes', $post_type, $post);
  • trunk/wp-admin/post.php

    r23823 r23929  
    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 ) {
  • trunk/wp-includes/revision.php

    r23928 r23929  
    587587
    588588/**
    589  * Upgrade the data
     589 * Upgrade the revisions author, add the current post as a revision and set the revisions version to 1
    590590 *
    591591 * @package WordPress
     
    593593 * @since 3.6.0
    594594 *
    595  * @uses get_post()
    596  * @uses post_type_supports()
    597595 * @uses wp_get_post_revisions()
    598596 *
    599  * @param int|object $post_id Post ID or post object
    600  * @return true if success, false if problems
    601  */
    602 function _wp_upgrade_revisions_of_post( $post ) {
     597 * @param object $post Post object
     598 * @param array $revisions Current revisions of the post
     599 * @return bool true if the revisions were upgraded, false if problems
     600 */
     601function _wp_upgrade_revisions_of_post( $post, $revisions ) {
    603602    global $wpdb;
    604 
    605     $post = get_post( $post );
    606     if ( ! $post )
    607         return false;
    608 
    609     if ( ! post_type_supports( $post->post_type, 'revisions' ) )
    610         return false;
    611 
    612     $revisions = wp_get_post_revisions( $post->ID ); // array( 'order' => 'DESC', 'orderby' => 'date' ); // Always work from most recent to oldest
    613 
    614     if ( ! $first = reset( $revisions ) )
    615         return true;
    616 
    617     // Check if the revisions have already been updated
    618     if ( preg_match( '/^\d+-(?:autosave|revision)-v\d+$/', $first->post_name ) )
    619         return true;
    620603
    621604    // Add post option exclusively
Note: See TracChangeset for help on using the changeset viewer.