Ticket #1930: comment_count_upgrade.diff

File comment_count_upgrade.diff, 713 bytes (added by markjaquith, 7 years ago)

patch for WP 2.0 SVN

  • upgrade-functions.php

     
    302302        } 
    303303 
    304304        // populate comment_count field of posts table 
    305         $comments = $wpdb->get_results( "SELECT comment_post_ID, COUNT(*) as c FROM $wpdb->comments GROUP BY comment_post_ID" ); 
     305        $comments = $wpdb->get_results( "SELECT comment_post_ID, COUNT(*) as c FROM $wpdb->comments WHERE comment_approved = '1' GROUP BY comment_post_ID" ); 
    306306        if( is_array( $comments ) ) { 
    307307                foreach ($comments as $comment) { 
    308308                        $wpdb->query( "UPDATE $wpdb->posts SET comment_count = $comment->c WHERE ID = '$comment->comment_post_ID'" );