Changeset 3104
- Timestamp:
- 11/16/2005 06:29:36 AM (19 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/list-manipulation.php
r3061 r3104 57 57 die('-1'); 58 58 59 if ( wp_set_comment_status($comment->comment_ID, "delete") ) { 60 do_action('delete_comment', $comment->comment_ID); 59 if ( wp_delete_comment($comment->comment_ID) ) { 61 60 die('1'); 62 61 } else { -
trunk/wp-admin/upgrade-functions.php
r3092 r3104 31 31 } 32 32 33 if ( $wp_current_db_version < 3 092)33 if ( $wp_current_db_version < 3104 ) 34 34 upgrade_160(); 35 35 … … 301 301 } 302 302 } 303 303 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" ); 306 if( is_array( $comments ) ) { 307 foreach ($comments as $comment) { 308 $wpdb->query( "UPDATE $wpdb->posts SET comment_count = $comment->c WHERE ID = '$comment->comment_post_ID}'" ); 309 } 310 } 311 304 312 // Some alpha versions used a post status of object instead of attachment and put 305 313 // the mime type in post_type instead of post_mime_type. -
trunk/wp-admin/upgrade-schema.php
r3092 r3104 122 122 post_type varchar(100) NOT NULL, 123 123 post_mime_type varchar(100) NOT NULL, 124 comment_count bigint(20) NOT NULL default '0', 124 125 PRIMARY KEY (ID), 125 126 KEY post_name (post_name) -
trunk/wp-includes/comment-functions.php
r3078 r3104 82 82 "); 83 83 84 return $wpdb->insert_id; 84 $id = $wpdb->insert_id; 85 86 if ( $comment_approved == 1) 87 $wpdb->query( "UPDATE $wpdb->posts SET comment_count = comment_count + 1 WHERE ID = '$comment_post_ID'" ); 88 89 return $id; 85 90 } 86 91 … … 177 182 $rval = $wpdb->rows_affected; 178 183 184 $c = $wpdb->get_row( "SELECT count(*) as c FROM {$wpdb->comments} WHERE comment_post_ID = '$comment_post_ID' AND comment_approved = '1'" ); 185 if( is_object( $c ) ) 186 $wpdb->query( "UPDATE $wpdb->posts SET comment_count = '$c->c' WHERE ID = '$comment_post_ID'" ); 187 179 188 do_action('edit_comment', $comment_ID); 180 189 181 return $rval; 190 return $rval; 191 } 192 193 function wp_delete_comment($comment_id) { 194 global $wpdb; 195 do_action('delete_comment', $comment_id); 196 197 $comment = get_comment($comment_id); 198 199 if ( ! $wpdb->query("DELETE FROM $wpdb->comments WHERE comment_ID='$comment_id' LIMIT 1") ) 200 return false; 201 202 $post_id = $comment->comment_post_ID; 203 if ( $post_id ) 204 $wpdb->query( "UPDATE $wpdb->posts SET comment_count = comment_count - 1 WHERE ID = '$post_id'" ); 205 206 do_action('wp_set_comment_status', $comment_id, 'delete'); 207 return true; 182 208 } 183 209 … … 199 225 200 226 if ( !isset($comment_count_cache[$post_id]) ) 201 $comment_count_cache[$ post_id] = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_post_ID = '$post_id' AND comment_approved = '1'");227 $comment_count_cache[$id] = $wpdb->get_var("SELECT comment_count FROM $wpdb->posts WHERE ID = '$post_id'"); 202 228 203 229 return apply_filters('get_comments_number', $comment_count_cache[$post_id]); … … 743 769 break; 744 770 case 'delete': 745 $query = "DELETE FROM $wpdb->comments WHERE comment_ID='$comment_id' LIMIT 1";771 return wp_delete_comment($comment_id); 746 772 break; 747 773 default: … … 751 777 if ($wpdb->query($query)) { 752 778 do_action('wp_set_comment_status', $comment_id, $comment_status); 779 780 $comment = get_comment($comment_id); 781 $comment_post_ID = $comment->comment_post_ID; 782 $c = $wpdb->get_row( "SELECT count(*) as c FROM {$wpdb->comments} WHERE comment_post_ID = '$comment_post_ID' AND comment_approved = '1'" ); 783 if( is_object( $c ) ) 784 $wpdb->query( "UPDATE $wpdb->posts SET comment_count = '$c->c' WHERE ID = '$comment_post_ID'" ); 753 785 return true; 754 786 } else { -
trunk/wp-includes/functions.php
r3103 r3104 1307 1307 1308 1308 // Do the same for comment numbers 1309 $comment_counts = $wpdb->get_results("SELECT comment_post_ID, COUNT( comment_ID ) AS ccount 1310 FROM $wpdb->comments 1311 WHERE comment_post_ID IN ($post_id_list) 1312 AND comment_approved = '1' 1313 GROUP BY comment_post_ID"); 1309 $comment_counts = $wpdb->get_results( "SELECT ID as comment_post_ID, comment_count as ccount FROM $wpdb->posts WHERE ID in ($post_id_list)" ); 1314 1310 1315 1311 if ( $comment_counts ) { -
trunk/wp-includes/version.php
r3092 r3104 4 4 5 5 $wp_version = '1.6-ALPHA-2-still-dont-use'; 6 $wp_db_version = 3 092;6 $wp_db_version = 3104; 7 7 8 8 ?>
Note: See TracChangeset
for help on using the changeset viewer.