From 6584fdf4ff40eebd2613927a3b61bb6ad8c39271 Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Tue, 22 Nov 2005 03:40:32 +0000 Subject: [PATCH] Count only approved comments. Props Mark JAquith. fixes #1930 git-svn-id: https://develop.svn.wordpress.org/trunk@3192 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-admin/upgrade-functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wp-admin/upgrade-functions.php b/wp-admin/upgrade-functions.php index 4392429834..35f35e7eb2 100644 --- a/wp-admin/upgrade-functions.php +++ b/wp-admin/upgrade-functions.php @@ -302,7 +302,7 @@ function upgrade_160() { } // populate comment_count field of posts table - $comments = $wpdb->get_results( "SELECT comment_post_ID, COUNT(*) as c FROM $wpdb->comments GROUP BY comment_post_ID" ); + $comments = $wpdb->get_results( "SELECT comment_post_ID, COUNT(*) as c FROM $wpdb->comments WHERE comment_approved = '1' GROUP BY comment_post_ID" ); if( is_array( $comments ) ) { foreach ($comments as $comment) { $wpdb->query( "UPDATE $wpdb->posts SET comment_count = $comment->c WHERE ID = '$comment->comment_post_ID'" );