WordPress.org

Make WordPress Core

Ticket #4387: comment.02.patch

File comment.02.patch, 1.7 KB (added by hovenko, 11 years ago)

This patch will clear the cache when comments gets deleted or updated

  • crypto/home/hovenko/workspace/NRK

     
    269269
    270270
    271271function wp_delete_comment($comment_id) {
    272         global $wpdb;
     272        global $comment_cache, $wpdb;
    273273        do_action('delete_comment', $comment_id);
    274274
    275275        $comment = get_comment($comment_id);
     
    276276
    277277        if ( ! $wpdb->query("DELETE FROM $wpdb->comments WHERE comment_ID='$comment_id' LIMIT 1") )
    278278                return false;
     279       
     280        unset($comment_cache[$comment_id]);
    279281
    280282        $post_id = $comment->comment_post_ID;
    281283        if ( $post_id && $comment->comment_approved == 1 )
     
    412414
    413415
    414416function wp_set_comment_status($comment_id, $comment_status) {
    415         global $wpdb;
     417        global $comment_cache, $wpdb;
    416418
    417419        switch ( $comment_status ) {
    418420                case 'hold':
     
    435437                return false;
    436438
    437439        do_action('wp_set_comment_status', $comment_id, $comment_status);
     440        unset($comment_cache[$comment_id]);
    438441        $comment = get_comment($comment_id);
    439442        wp_update_comment_count($comment->comment_post_ID);
    440443        return true;
     
    442445
    443446
    444447function wp_update_comment($commentarr) {
    445         global $wpdb;
     448        global $comment_cache, $wpdb;
    446449
    447450        // First, get all of the original fields
    448451        $comment = get_comment($commentarr['comment_ID'], ARRAY_A);
     
    475478                WHERE comment_ID = $comment_ID" );
    476479
    477480        $rval = $wpdb->rows_affected;
     481        unset($comment_cache[$comment_ID]);
    478482        wp_update_comment_count($comment_post_ID);
    479483        do_action('edit_comment', $comment_ID);
    480484        return $rval;