Changeset 3888

Show
Ignore:
Timestamp:
06/19/06 17:18:19 (3 years ago)
Author:
ryan
Message:

wp_update_comment_count() from MarkJaquith?. fixes #2836

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • 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');