Ticket #16215: 16215.diff
File 16215.diff, 5.7 KB (added by , 13 years ago) |
---|
-
wp-includes/default-filters.php
126 126 add_filter( $filter, 'convert_chars' ); 127 127 } 128 128 129 // Pre save Revision Version 130 add_filter( 'wp_insert_post_data', '_wp_insert_post_data_revision_version', 10, 2 ); 131 129 132 // Pre save hierarchy 130 133 add_filter( 'wp_insert_post_parent', 'wp_check_post_hierarchy_for_loops', 10, 2 ); 131 134 add_filter( 'wp_update_term_parent', 'wp_check_term_hierarchy_for_loops', 10, 3 ); -
wp-includes/post-template.php
1356 1356 $rows = $right_checked = ''; 1357 1357 $class = false; 1358 1358 $can_edit_post = current_user_can( 'edit_post', $post->ID ); 1359 1359 1360 foreach ( $revisions as $revision ) { 1360 1361 if ( !current_user_can( 'read_post', $revision->ID ) ) 1361 1362 continue; … … 1363 1364 continue; 1364 1365 1365 1366 $date = wp_post_revision_title( $revision ); 1366 $name = get_the_author_meta( 'display_name', $revision->post_author ); 1367 if ( wp_is_post_revision( $revision ) ) { 1368 $revision_author_id = $revision->post_author; 1369 } elseif ( !$revision_author_id = get_post_meta( $revision->ID, '_edit_last', true ) ) { 1370 $revision_author_id = $revision->post_author; 1371 } 1367 1372 1373 $name = get_the_author_meta( 'display_name', $revision_author_id ); 1374 1368 1375 if ( 'form-table' == $format ) { 1369 1376 if ( $left ) 1370 1377 $left_checked = $left == $revision->ID ? ' checked="checked"' : ''; -
wp-includes/post.php
2592 2592 $wpdb->update( $wpdb->posts, array( 'post_name' => $data['post_name'] ), $where ); 2593 2593 } 2594 2594 2595 update_post_meta( $post_ID, '_edit_last', $user_ID ); 2596 2595 2597 if ( is_object_in_taxonomy($post_type, 'category') ) 2596 2598 wp_set_post_categories( $post_ID, $post_category ); 2597 2599 … … 4710 4712 $return['post_date'] = isset($post['post_modified']) ? $post['post_modified'] : ''; 4711 4713 $return['post_date_gmt'] = isset($post['post_modified_gmt']) ? $post['post_modified_gmt'] : ''; 4712 4714 4715 $return['post_author'] = get_post_meta( $post['ID'], '_edit_last', true ); 4716 $return['comment_count'] = 1; // The comment_count field stores the revisioning system version 4717 4713 4718 return $return; 4714 4719 } 4715 4720 4721 function _wp_insert_post_data_revision_version( $data, $post_array ) { 4722 if ( 'revision' != $data['post_type'] ) { 4723 return $data; 4724 } 4725 4726 if ( isset( $post_array['comment_count'] ) ) { 4727 $data['comment_count'] = (int) $post_array['comment_count']; 4728 } 4729 4730 return $data; 4731 } 4732 4716 4733 /** 4717 4734 * Saves an already existing post as a post revision. 4718 4735 * … … 5022 5039 5023 5040 if ( !$revisions = get_children( $args ) ) 5024 5041 return array(); 5042 5043 $revisions = wp_fix_post_revision_authors( $revisions, $args ); 5025 5044 return $revisions; 5026 5045 } 5027 5046 5047 function wp_fix_post_revision_authors( $revisions, $args ) { 5048 $keys = array_keys( $revisions ); 5049 if ( 'DESC' == strtoupper( $args['order'] ) ) { 5050 $keys = array_reverse( $keys ); 5051 } 5052 5053 $previous_author = false; 5054 foreach ( $keys as $key ) { 5055 if ( is_array( $revisions[$key] ) && isset( $revisions[$key]['comment_count'] ) ) { 5056 $revision_version = $revisions[$key]['comment_count']; 5057 $is_array = true; 5058 } elseif ( is_object( $revisions[$key] ) && isset( $revisions[$key]->comment_count ) ) { 5059 $revision_version = $revisions[$key]->comment_count; 5060 $is_array = false; 5061 } else { 5062 continue; 5063 } 5064 5065 if ( 1 == $revision_version ) { 5066 $post_author_name = get_the_author_meta( 'display_name', $revisions[$key]->post_author ); 5067 continue; 5068 } 5069 5070 if ( $is_array ) { 5071 // swap 5072 list( 5073 $previous_author, 5074 $revisions[$key]['post_author'] 5075 ) = array( 5076 $revisions[$key]['post_author'], 5077 false === $previous_author ? $revisions[$key]['post_author'] : $previous_author 5078 ); 5079 $revisions[$key]['comment_count'] = 1; // in case this data gets cached somewhere, flag it as having the fixed post_author 5080 } else { 5081 // swap 5082 list( 5083 $previous_author, 5084 $revisions[$key]->post_author 5085 ) = array( 5086 $revisions[$key]->post_author, 5087 false === $previous_author ? $revisions[$key]->post_author : $previous_author 5088 ); 5089 $revisions[$key]->comment_count = 1; // in case this data gets cached somewhere, flag it as having the fixed post_author 5090 } 5091 } 5092 5093 return $revisions; 5094 } 5095 5028 5096 function _set_preview($post) { 5029 5097 5030 5098 if ( ! is_object($post) ) -
wp-includes/comment.php
1563 1563 return false; 1564 1564 if ( !$post = get_post($post_id) ) 1565 1565 return false; 1566 if ( 'revision' == $post->post_type ) 1567 return false; 1566 1568 1567 1569 $old = (int) $post->comment_count; 1568 1570 $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
230 230 231 231 add_meta( $post_ID ); 232 232 233 update_post_meta( $post_ID, '_edit_last', $GLOBALS['current_user']->ID );234 235 233 wp_update_post( $post_data ); 236 234 237 235 // Reunite any orphaned attachments with their parent … … 609 607 610 608 add_meta( $post_ID ); 611 609 612 add_post_meta( $post_ID, '_edit_last', $GLOBALS['current_user']->ID );613 614 610 // Reunite any orphaned attachments with their parent 615 611 // Does this need to be updated? ~ Mark 616 612 if ( !$draft_ids = get_user_option( 'autosave_draft_ids' ) )