Changeset 3193

Show
Ignore:
Timestamp:
11/22/05 03:45:40 (3 years ago)
Author:
ryan
Message:

Instead of incrementing the current comment count, recount all comments to make sure we have a good count. Props Mark Jaquith. fixes #1920

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/wp-includes/comment-functions.php

    r3145 r3193  
    8484    $id = $wpdb->insert_id; 
    8585 
    86     if ( $comment_approved == 1) 
    87         $wpdb->query( "UPDATE $wpdb->posts SET comment_count = comment_count + 1 WHERE ID = '$comment_post_ID'" ); 
    88      
     86    if ( $comment_approved == 1) { 
     87        $count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_post_ID = '$comment_post_ID' AND comment_approved = '1'"); 
     88        $wpdb->query( "UPDATE $wpdb->posts SET comment_count = $count WHERE ID = '$comment_post_ID'" ); 
     89    } 
    8990    return $id; 
    9091}