Ticket #16215: 16215-16.patch
File 16215-16.patch, 3.1 KB (added by , 12 years ago) |
---|
-
wp-admin/edit-form-advanced.php
227 227 add_meta_box('authordiv', __('Author'), 'post_author_meta_box', null, 'normal', 'core'); 228 228 } 229 229 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'); 230 if ( post_type_supports($post_type, 'revisions') && 'auto-draft' != $post->post_status ) { 231 $revisions = wp_get_post_revisions( $post_ID ); 233 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 } 241 234 242 do_action('add_meta_boxes', $post_type, $post); 235 243 do_action('add_meta_boxes_' . $post_type, $post); 236 244 -
wp-admin/post.php
154 154 exit(); 155 155 } 156 156 157 //upgrade any old bad revision data (#16215)158 _wp_upgrade_revisions_of_post( $p );159 160 157 $post_type = $post->post_type; 161 158 if ( 'post' == $post_type ) { 162 159 $parent_file = "edit.php"; -
wp-includes/revision.php
554 554 } 555 555 556 556 /** 557 * Upgrade the data557 * Upgrade the revisions author, add the current post as a revision and set the revisions version to 1 558 558 * 559 559 * @package WordPress 560 560 * @subpackage Post_Revisions 561 561 * @since 3.6.0 562 562 * 563 * @uses get_post()564 * @uses post_type_supports()565 563 * @uses wp_get_post_revisions() 566 564 * 567 * @param int|object $post_id Post ID or post object568 * @return true if success, false if problems565 * @param object Post object 566 * @return bool true if the revisions were upgraded, false if problems 569 567 */ 570 function _wp_upgrade_revisions_of_post( $post ) {568 function _wp_upgrade_revisions_of_post( $post, $revisions ) { 571 569 global $wpdb; 572 570 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 oldest581 582 if ( ! $first = reset( $revisions ) )583 return true;584 585 // Check if the revisions have already been updated586 if ( preg_match( '/^\d+-(?:autosave|revision)-v\d+$/', $first->post_name ) )587 return true;588 589 571 // Add post option exclusively 590 572 $lock = "revision-upgrade-{$post->ID}"; 591 573 $now = time();