Make WordPress Core

Changeset 3193


Ignore:
Timestamp:
11/22/2005 03:45:40 AM (19 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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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}
Note: See TracChangeset for help on using the changeset viewer.