Make WordPress Core


Ignore:
Timestamp:
09/15/2015 12:57:48 AM (10 years ago)
Author:
wonderboymusic
Message:

More bonkers comment cache cleanup: toggle wp_defer_comment_counting() in wp_insert_post() and wp_insert_attachment(). Move the cache deletion in wp_update_comment_count_now() to before the get_post() call, so that the caches get deleted even if the post has already been deleted and the function returns early.

See #33875.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/post-functions.php

    r34102 r34158  
    13951395    $labels = array_merge( $defaults, $object->labels );
    13961396    $object->labels = (object) $object->labels;
    1397    
     1397
    13981398    return (object) $labels;
    13991399}
     
    23712371    $wpdb->update( $wpdb->posts, $parent_data, $parent_where + array( 'post_type' => 'attachment' ) );
    23722372
     2373    wp_defer_comment_counting( true );
     2374
    23732375    $comment_ids = $wpdb->get_col( $wpdb->prepare( "SELECT comment_ID FROM $wpdb->comments WHERE comment_post_ID = %d", $postid ));
    2374     foreach ( $comment_ids as $comment_id )
     2376    foreach ( $comment_ids as $comment_id ) {
    23752377        wp_delete_comment( $comment_id, true );
     2378    }
     2379
     2380    wp_defer_comment_counting( false );
    23762381
    23772382    $post_meta_ids = $wpdb->get_col( $wpdb->prepare( "SELECT meta_id FROM $wpdb->postmeta WHERE post_id = %d ", $postid ));
     
    46384643    delete_metadata( 'post', null, '_thumbnail_id', $post_id, true );
    46394644
     4645    wp_defer_comment_counting( true );
     4646
    46404647    $comment_ids = $wpdb->get_col( $wpdb->prepare( "SELECT comment_ID FROM $wpdb->comments WHERE comment_post_ID = %d", $post_id ));
    4641     foreach ( $comment_ids as $comment_id )
     4648    foreach ( $comment_ids as $comment_id ) {
    46424649        wp_delete_comment( $comment_id, true );
     4650    }
     4651   
     4652    wp_defer_comment_counting( false );
    46434653
    46444654    $post_meta_ids = $wpdb->get_col( $wpdb->prepare( "SELECT meta_id FROM $wpdb->postmeta WHERE post_id = %d ", $post_id ));
Note: See TracChangeset for help on using the changeset viewer.