Ticket #16215: 16215-15.patch
File 16215-15.patch, 2.3 KB (added by , 12 years ago) |
---|
-
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
434 434 * @return array empty if no revisions 435 435 */ 436 436 function wp_get_post_revisions( $post_id = 0, $args = null ) { 437 static $checked = array(); 438 437 439 $post = get_post( $post_id ); 438 440 if ( ! $post || empty( $post->ID ) || ! wp_revisions_enabled( $post ) ) 439 441 return array(); … … 445 447 if ( ! $revisions = get_children( $args ) ) 446 448 return array(); 447 449 450 if ( ! in_array( $post->ID, $checked ) ) { 451 $checked[] = $post->ID; 452 453 // Check if the revisions have already been updated 454 if ( 1 > _wp_get_post_revision_version( reset( $revisions ) ) ) 455 return $revisions; 456 457 if ( _wp_upgrade_revisions_of_post( $post, $revisions ) ) 458 return wp_get_post_revisions( $post, $args ); 459 } 460 448 461 return $revisions; 449 462 } 450 463 … … 564 577 * @uses post_type_supports() 565 578 * @uses wp_get_post_revisions() 566 579 * 567 * @param int|object $post_id Post ID or post object568 * @return true if success, false if problems580 * @param object Post object 581 * @return bool true if the revisions were upgraded, false if problems 569 582 */ 570 function _wp_upgrade_revisions_of_post( $post ) {583 function _wp_upgrade_revisions_of_post( $post, $revisions ) { 571 584 global $wpdb; 572 585 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 586 // Add post option exclusively 590 587 $lock = "revision-upgrade-{$post->ID}"; 591 588 $now = time();