Ticket #16215: combined-3.diff
File combined-3.diff, 8.4 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 ); … … 249 252 add_action( 'plugins_loaded', 'wp_maybe_load_widgets', 0 ); 250 253 add_action( 'plugins_loaded', 'wp_maybe_load_embeds', 0 ); 251 254 add_action( 'shutdown', 'wp_ob_end_flush_all', 1 ); 252 add_action( 'pre_post_update', 'wp_save_post_revision' 255 add_action( 'pre_post_update', 'wp_save_post_revision', 10, 2 ); 253 256 add_action( 'publish_post', '_publish_post_hook', 5, 1 ); 254 257 add_action( 'transition_post_status', '_transition_post_status', 5, 3 ); 255 258 add_action( 'transition_post_status', '_update_term_count_on_transition_post_status', 10, 3 ); -
wp-includes/post-template.php
1375 1375 1376 1376 if ( $parent ) 1377 1377 array_unshift( $revisions, $post ); 1378 1379 if ( ! array_pop( $revisions ) ) 1380 return; 1378 1381 1379 1382 $rows = $right_checked = ''; 1380 1383 $class = false; 1381 1384 $can_edit_post = current_user_can( 'edit_post', $post->ID ); 1385 1382 1386 foreach ( $revisions as $revision ) { 1387 1383 1388 if ( !current_user_can( 'read_post', $revision->ID ) ) 1384 1389 continue; 1385 1390 if ( 'revision' === $type && wp_is_post_autosave( $revision ) ) 1386 1391 continue; 1387 1392 1388 1393 $date = wp_post_revision_title( $revision ); 1389 $name = get_the_author_meta( 'display_name', $revision->post_author ); 1394 if ( wp_is_post_revision( $revision ) ) { 1395 $revision_author_id = $revision->post_author; 1396 } elseif ( !$revision_author_id = get_post_meta( $revision->ID, '_edit_last', true ) ) { 1397 $revision_author_id = $revision->post_author; 1398 } 1399 $name = get_the_author_meta( 'display_name', $revision_author_id ); 1390 1400 1391 1401 if ( 'form-table' == $format ) { 1392 1402 if ( $left ) -
wp-includes/post.php
2866 2866 $where = array( 'ID' => $post_ID ); 2867 2867 2868 2868 if ( $update ) { 2869 do_action( 'pre_post_update', $post_ID );2869 do_action( 'pre_post_update', $post_ID, $data ); 2870 2870 if ( false === $wpdb->update( $wpdb->posts, $data, $where ) ) { 2871 2871 if ( $wp_error ) 2872 2872 return new WP_Error('db_update_error', __('Could not update post in the database'), $wpdb->last_error); … … 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 * … … 4937 4954 * @param int $post_id The ID of the post to save as a revision. 4938 4955 * @return mixed Null or 0 if error, new revision ID, if success. 4939 4956 */ 4940 function wp_save_post_revision( $post_id ) {4957 function wp_save_post_revision( $post_id, $new_data = null ) { 4941 4958 // We do autosaves manually with wp_create_post_autosave() 4942 4959 if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) 4943 4960 return; … … 4955 4972 if ( !post_type_supports($post['post_type'], 'revisions') ) 4956 4973 return; 4957 4974 4975 // if new data is supplied, check that it is different from last saved revision 4976 if( is_array( $new_data ) ) { 4977 $post_has_changed = false; 4978 foreach( array_keys( _wp_post_revision_fields() ) as $field ) { 4979 if( normalize_whitespace( $new_data[ $field ] ) != normalize_whitespace( $post[$field] ) ) { 4980 error_log( 'post changed' ); 4981 $post_has_changed = true; 4982 break; 4983 } 4984 } 4985 //don't save revision if post unchanged 4986 if( ! $post_has_changed ) 4987 return; 4988 } 4989 4958 4990 $return = _wp_put_post_revision( $post ); 4959 4991 4960 4992 // WP_POST_REVISIONS = true (default), -1 … … 5235 5267 5236 5268 if ( !$revisions = get_children( $args ) ) 5237 5269 return array(); 5270 5271 $revisions = wp_fix_post_revision_authors( $revisions, $args ); 5238 5272 return $revisions; 5239 5273 } 5240 5274 5275 function wp_fix_post_revision_authors( $revisions, $args ) { 5276 $keys = array_keys( $revisions ); 5277 if ( 'DESC' == strtoupper( $args['order'] ) ) { 5278 $keys = array_reverse( $keys ); 5279 } 5280 5281 $previous_author = false; 5282 foreach ( $keys as $key ) { 5283 if ( is_array( $revisions[$key] ) && isset( $revisions[$key]['comment_count'] ) ) { 5284 $revision_version = $revisions[$key]['comment_count']; 5285 $is_array = true; 5286 } elseif ( is_object( $revisions[$key] ) && isset( $revisions[$key]->comment_count ) ) { 5287 $revision_version = $revisions[$key]->comment_count; 5288 $is_array = false; 5289 } else { 5290 continue; 5291 } 5292 5293 if ( 1 == $revision_version ) { 5294 $post_author_name = get_the_author_meta( 'display_name', $revisions[$key]->post_author ); 5295 continue; 5296 } 5297 5298 if ( $is_array ) { 5299 // swap 5300 list( 5301 $previous_author, 5302 $revisions[$key]['post_author'] 5303 ) = array( 5304 $revisions[$key]['post_author'], 5305 false === $previous_author ? $revisions[$key]['post_author'] : $previous_author 5306 ); 5307 $revisions[$key]['comment_count'] = 1; // in case this data gets cached somewhere, flag it as having the fixed post_author 5308 } else { 5309 // swap 5310 list( 5311 $previous_author, 5312 $revisions[$key]->post_author 5313 ) = array( 5314 $revisions[$key]->post_author, 5315 false === $previous_author ? $revisions[$key]->post_author : $previous_author 5316 ); 5317 $revisions[$key]->comment_count = 1; // in case this data gets cached somewhere, flag it as having the fixed post_author 5318 } 5319 } 5320 5321 return $revisions; 5322 } 5323 5241 5324 function _set_preview($post) { 5242 5325 5243 5326 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 -
wp-admin/includes/meta-boxes.php
603 603 * @param object $post 604 604 */ 605 605 function post_revisions_meta_box($post) { 606 wp_list_post_revisions(); 606 $args = array( 'parent' => true ); 607 wp_list_post_revisions( $post, $args ); 607 608 } 608 609 609 610 // -- Page related Meta Boxes