Ticket #16215: 16215-1.diff

File 16215-1.diff, 5.7 KB (added by adamsilverstein, 4 months ago)

only update is applies cleanly to current trunk

  • wp-includes/default-filters.php

     
    123123        add_filter( $filter, 'convert_chars' ); 
    124124} 
    125125 
     126// Pre save Revision Version 
     127add_filter( 'wp_insert_post_data', '_wp_insert_post_data_revision_version', 10, 2 ); 
     128 
    126129// Pre save hierarchy 
    127130add_filter( 'wp_insert_post_parent', 'wp_check_post_hierarchy_for_loops', 10, 2 ); 
    128131add_filter( 'wp_update_term_parent', 'wp_check_term_hierarchy_for_loops', 10, 3 ); 
  • wp-includes/post-template.php

     
    13791379        $rows = $right_checked = ''; 
    13801380        $class = false; 
    13811381        $can_edit_post = current_user_can( 'edit_post', $post->ID ); 
     1382 
    13821383        foreach ( $revisions as $revision ) { 
    13831384                if ( !current_user_can( 'read_post', $revision->ID ) ) 
    13841385                        continue; 
     
    13861387                        continue; 
    13871388 
    13881389                $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                } 
    13901395 
     1396                $name = get_the_author_meta( 'display_name', $revision_author_id ); 
     1397 
    13911398                if ( 'form-table' == $format ) { 
    13921399                        if ( $left ) 
    13931400                                $left_checked = $left == $revision->ID ? ' checked="checked"' : ''; 
  • wp-includes/post.php

     
    29002900                $wpdb->update( $wpdb->posts, array( 'post_name' => $data['post_name'] ), $where ); 
    29012901        } 
    29022902 
     2903        update_post_meta( $post_ID, '_edit_last', $user_ID ); 
     2904 
    29032905        if ( is_object_in_taxonomy($post_type, 'category') ) 
    29042906                wp_set_post_categories( $post_ID, $post_category ); 
    29052907 
     
    49204922        $return['post_date']     = isset($post['post_modified']) ? $post['post_modified'] : ''; 
    49214923        $return['post_date_gmt'] = isset($post['post_modified_gmt']) ? $post['post_modified_gmt'] : ''; 
    49224924 
     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 
    49234928        return $return; 
    49244929} 
    49254930 
     4931function _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 
    49264943/** 
    49274944 * Saves an already existing post as a post revision. 
    49284945 * 
     
    52355252 
    52365253        if ( !$revisions = get_children( $args ) ) 
    52375254                return array(); 
     5255 
     5256        $revisions = wp_fix_post_revision_authors( $revisions, $args ); 
    52385257        return $revisions; 
    52395258} 
    52405259 
     5260function 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 
    52415309function _set_preview($post) { 
    52425310 
    52435311        if ( ! is_object($post) ) 
  • wp-includes/comment.php

     
    16151615                return false; 
    16161616        if ( !$post = get_post($post_id) ) 
    16171617                return false; 
     1618        if ( 'revision' == $post->post_type ) 
     1619                return false; 
    16181620 
    16191621        $old = (int) $post->comment_count; 
    16201622        $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

     
    241241 
    242242        add_meta( $post_ID ); 
    243243 
    244         update_post_meta( $post_ID, '_edit_last', $GLOBALS['current_user']->ID ); 
    245  
    246244        wp_update_post( $post_data ); 
    247245 
    248246        // Now that we have an ID we can fix any attachment anchor hrefs 
     
    568566 
    569567        add_meta( $post_ID ); 
    570568 
    571         add_post_meta( $post_ID, '_edit_last', $GLOBALS['current_user']->ID ); 
    572  
    573569        // Now that we have an ID we can fix any attachment anchor hrefs 
    574570        _fix_attachment_links( $post_ID ); 
    575571