Ticket #16215: 16215-1.diff
File 16215-1.diff, 5.7 KB (added by , 12 years ago) |
---|
-
wp-includes/default-filters.php
123 123 add_filter( $filter, 'convert_chars' ); 124 124 } 125 125 126 // Pre save Revision Version 127 add_filter( 'wp_insert_post_data', '_wp_insert_post_data_revision_version', 10, 2 ); 128 126 129 // Pre save hierarchy 127 130 add_filter( 'wp_insert_post_parent', 'wp_check_post_hierarchy_for_loops', 10, 2 ); 128 131 add_filter( 'wp_update_term_parent', 'wp_check_term_hierarchy_for_loops', 10, 3 ); -
wp-includes/post-template.php
1379 1379 $rows = $right_checked = ''; 1380 1380 $class = false; 1381 1381 $can_edit_post = current_user_can( 'edit_post', $post->ID ); 1382 1382 1383 foreach ( $revisions as $revision ) { 1383 1384 if ( !current_user_can( 'read_post', $revision->ID ) ) 1384 1385 continue; … … 1386 1387 continue; 1387 1388 1388 1389 $date = wp_post_revision_title( $revision ); 1389 $name = get_the_author_meta( 'display_name', $revision->post_author ); 1390 if ( wp_is_post_revision( $revision ) ) { 1391 $revision_author_id = $revision->post_author; 1392 } elseif ( !$revision_author_id = get_post_meta( $revision->ID, '_edit_last', true ) ) { 1393 $revision_author_id = $revision->post_author; 1394 } 1390 1395 1396 $name = get_the_author_meta( 'display_name', $revision_author_id ); 1397 1391 1398 if ( 'form-table' == $format ) { 1392 1399 if ( $left ) 1393 1400 $left_checked = $left == $revision->ID ? ' checked="checked"' : ''; -
wp-includes/post.php
2900 2900 $wpdb->update( $wpdb->posts, array( 'post_name' => $data['post_name'] ), $where ); 2901 2901 } 2902 2902 2903 update_post_meta( $post_ID, '_edit_last', $user_ID ); 2904 2903 2905 if ( is_object_in_taxonomy($post_type, 'category') ) 2904 2906 wp_set_post_categories( $post_ID, $post_category ); 2905 2907 … … 4920 4922 $return['post_date'] = isset($post['post_modified']) ? $post['post_modified'] : ''; 4921 4923 $return['post_date_gmt'] = isset($post['post_modified_gmt']) ? $post['post_modified_gmt'] : ''; 4922 4924 4925 $return['post_author'] = get_post_meta( $post['ID'], '_edit_last', true ); 4926 $return['comment_count'] = 1; // The comment_count field stores the revisioning system version 4927 4923 4928 return $return; 4924 4929 } 4925 4930 4931 function _wp_insert_post_data_revision_version( $data, $post_array ) { 4932 if ( 'revision' != $data['post_type'] ) { 4933 return $data; 4934 } 4935 4936 if ( isset( $post_array['comment_count'] ) ) { 4937 $data['comment_count'] = (int) $post_array['comment_count']; 4938 } 4939 4940 return $data; 4941 } 4942 4926 4943 /** 4927 4944 * Saves an already existing post as a post revision. 4928 4945 * … … 5235 5252 5236 5253 if ( !$revisions = get_children( $args ) ) 5237 5254 return array(); 5255 5256 $revisions = wp_fix_post_revision_authors( $revisions, $args ); 5238 5257 return $revisions; 5239 5258 } 5240 5259 5260 function wp_fix_post_revision_authors( $revisions, $args ) { 5261 $keys = array_keys( $revisions ); 5262 if ( 'DESC' == strtoupper( $args['order'] ) ) { 5263 $keys = array_reverse( $keys ); 5264 } 5265 5266 $previous_author = false; 5267 foreach ( $keys as $key ) { 5268 if ( is_array( $revisions[$key] ) && isset( $revisions[$key]['comment_count'] ) ) { 5269 $revision_version = $revisions[$key]['comment_count']; 5270 $is_array = true; 5271 } elseif ( is_object( $revisions[$key] ) && isset( $revisions[$key]->comment_count ) ) { 5272 $revision_version = $revisions[$key]->comment_count; 5273 $is_array = false; 5274 } else { 5275 continue; 5276 } 5277 5278 if ( 1 == $revision_version ) { 5279 $post_author_name = get_the_author_meta( 'display_name', $revisions[$key]->post_author ); 5280 continue; 5281 } 5282 5283 if ( $is_array ) { 5284 // swap 5285 list( 5286 $previous_author, 5287 $revisions[$key]['post_author'] 5288 ) = array( 5289 $revisions[$key]['post_author'], 5290 false === $previous_author ? $revisions[$key]['post_author'] : $previous_author 5291 ); 5292 $revisions[$key]['comment_count'] = 1; // in case this data gets cached somewhere, flag it as having the fixed post_author 5293 } else { 5294 // swap 5295 list( 5296 $previous_author, 5297 $revisions[$key]->post_author 5298 ) = array( 5299 $revisions[$key]->post_author, 5300 false === $previous_author ? $revisions[$key]->post_author : $previous_author 5301 ); 5302 $revisions[$key]->comment_count = 1; // in case this data gets cached somewhere, flag it as having the fixed post_author 5303 } 5304 } 5305 5306 return $revisions; 5307 } 5308 5241 5309 function _set_preview($post) { 5242 5310 5243 5311 if ( ! is_object($post) ) -
wp-includes/comment.php
1615 1615 return false; 1616 1616 if ( !$post = get_post($post_id) ) 1617 1617 return false; 1618 if ( 'revision' == $post->post_type ) 1619 return false; 1618 1620 1619 1621 $old = (int) $post->comment_count; 1620 1622 $new = (int) $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_approved = '1'", $post_id) ); -
wp-admin/includes/post.php
241 241 242 242 add_meta( $post_ID ); 243 243 244 update_post_meta( $post_ID, '_edit_last', $GLOBALS['current_user']->ID );245 246 244 wp_update_post( $post_data ); 247 245 248 246 // Now that we have an ID we can fix any attachment anchor hrefs … … 568 566 569 567 add_meta( $post_ID ); 570 568 571 add_post_meta( $post_ID, '_edit_last', $GLOBALS['current_user']->ID );572 573 569 // Now that we have an ID we can fix any attachment anchor hrefs 574 570 _fix_attachment_links( $post_ID ); 575 571