Make WordPress Core

Changeset 3888


Ignore:
Timestamp:
06/19/2006 05:18:19 PM (19 years ago)
Author:
ryan
Message:

wp_update_comment_count() from MarkJaquith. fixes #2836

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.0/wp-includes/comment-functions.php

    r3873 r3888  
    222222
    223223    $post_id = $comment->comment_post_ID;
    224     if ( $post_id && $comment->comment_approved == 1 )
    225         $wpdb->query( "UPDATE $wpdb->posts SET comment_count = comment_count - 1 WHERE ID = '$post_id'" );
     224    if ( $post_id && $comment->comment_approved == 1 ) {
     225        $count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_post_ID = '$post_id' AND comment_approved = '1'");
     226        $wpdb->query( "UPDATE $wpdb->posts SET comment_count = $count WHERE ID = '$post_id'" );
     227    }
    226228
    227229    do_action('wp_set_comment_status', $comment_id, 'delete');
Note: See TracChangeset for help on using the changeset viewer.