Ticket #1930: comment_count_upgrade.diff
| File comment_count_upgrade.diff, 713 bytes (added by markjaquith, 7 years ago) |
|---|
-
upgrade-functions.php
302 302 } 303 303 304 304 // 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" ); 306 306 if( is_array( $comments ) ) { 307 307 foreach ($comments as $comment) { 308 308 $wpdb->query( "UPDATE $wpdb->posts SET comment_count = $comment->c WHERE ID = '$comment->comment_post_ID'" );
