Add comment_count to the posts table. Props donncha. fixes #1860
git-svn-id: http://svn.automattic.com/wordpress/trunk@3104 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
@@ -56,8 +56,7 @@ case 'delete-comment' :
|
||||
if ( !current_user_can('edit_post', $comment->comment_post_ID) )
|
||||
die('-1');
|
||||
|
||||
if ( wp_set_comment_status($comment->comment_ID, "delete") ) {
|
||||
do_action('delete_comment', $comment->comment_ID);
|
||||
if ( wp_delete_comment($comment->comment_ID) ) {
|
||||
die('1');
|
||||
} else {
|
||||
die('0');
|
||||
|
||||
@@ -30,7 +30,7 @@ function upgrade_all() {
|
||||
upgrade_130();
|
||||
}
|
||||
|
||||
if ( $wp_current_db_version < 3092 )
|
||||
if ( $wp_current_db_version < 3104 )
|
||||
upgrade_160();
|
||||
|
||||
save_mod_rewrite_rules();
|
||||
@@ -300,7 +300,15 @@ function upgrade_160() {
|
||||
$wpdb->query("UPDATE $wpdb->categories SET category_count = '$count' WHERE cat_ID = '$cat_id'");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 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" );
|
||||
if( is_array( $comments ) ) {
|
||||
foreach ($comments as $comment) {
|
||||
$wpdb->query( "UPDATE $wpdb->posts SET comment_count = $comment->c WHERE ID = '$comment->comment_post_ID}'" );
|
||||
}
|
||||
}
|
||||
|
||||
// Some alpha versions used a post status of object instead of attachment and put
|
||||
// the mime type in post_type instead of post_mime_type.
|
||||
if ( $wp_current_db_version > 2541 && $wp_current_db_version <= 3091 ) {
|
||||
|
||||
@@ -121,6 +121,7 @@ CREATE TABLE $wpdb->posts (
|
||||
menu_order int(11) NOT NULL default '0',
|
||||
post_type varchar(100) NOT NULL,
|
||||
post_mime_type varchar(100) NOT NULL,
|
||||
comment_count bigint(20) NOT NULL default '0',
|
||||
PRIMARY KEY (ID),
|
||||
KEY post_name (post_name)
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user