summaryrefslogtreecommitdiffstats
path: root/wp-inst/wp-includes/comment.php
diff options
context:
space:
mode:
authordonncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36>2006-06-20 10:39:28 +0000
committerdonncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36>2006-06-20 10:39:28 +0000
commit4ebc9ae74b80b06ce5c5a215bb672b795642d56a (patch)
tree7a4224f5f146f95032ca387ba949689fdf997db4 /wp-inst/wp-includes/comment.php
parentd0d9e6ad956ddf6aa3fbeb247f1a1894973077d5 (diff)
downloadwordpress-mu-4ebc9ae74b80b06ce5c5a215bb672b795642d56a.tar.gz
wordpress-mu-4ebc9ae74b80b06ce5c5a215bb672b795642d56a.tar.xz
wordpress-mu-4ebc9ae74b80b06ce5c5a215bb672b795642d56a.zip
WP Merge
git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@579 7be80a69-a1ef-0310-a953-fb0f7c49ff36
Diffstat (limited to 'wp-inst/wp-includes/comment.php')
-rw-r--r--wp-inst/wp-includes/comment.php24
1 files changed, 16 insertions, 8 deletions
diff --git a/wp-inst/wp-includes/comment.php b/wp-inst/wp-includes/comment.php
index 45547db..9751c36 100644
--- a/wp-inst/wp-includes/comment.php
+++ b/wp-inst/wp-includes/comment.php
@@ -252,7 +252,7 @@ function wp_delete_comment($comment_id) {
$post_id = $comment->comment_post_ID;
if ( $post_id && $comment->comment_approved == 1 )
- $wpdb->query( "UPDATE $wpdb->posts SET comment_count = comment_count - 1 WHERE ID = '$post_id'" );
+ wp_update_comment_count($post_id);
do_action('wp_set_comment_status', $comment_id, 'delete');
return true;
@@ -300,10 +300,9 @@ function wp_insert_comment($commentdata) {
$id = $wpdb->insert_id;
- if ( $comment_approved == 1) {
- $count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_post_ID = '$comment_post_ID' AND comment_approved = '1'");
- $wpdb->query( "UPDATE $wpdb->posts SET comment_count = $count WHERE ID = '$comment_post_ID'" );
- }
+ if ( $comment_approved == 1)
+ wp_update_comment_count($comment_post_ID);
+
return $id;
}
@@ -419,15 +418,24 @@ function wp_update_comment($commentarr) {
$rval = $wpdb->rows_affected;
- $c = $wpdb->get_row( "SELECT count(*) as c FROM {$wpdb->comments} WHERE comment_post_ID = '$comment_post_ID' AND comment_approved = '1'" );
- if( is_object( $c ) )
- $wpdb->query( "UPDATE $wpdb->posts SET comment_count = '$c->c' WHERE ID = '$comment_post_ID'" );
+ wp_update_comment_count($comment_post_ID);
do_action('edit_comment', $comment_ID);
return $rval;
}
+function wp_update_comment_count($post_id) {
+ global $wpdb, $comment_count_cache;
+ $post_id = (int) $post_id;
+ if ( !$post_id )
+ return false;
+ $count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_post_ID = '$post_id' AND comment_approved = '1'");
+ $wpdb->query("UPDATE $wpdb->posts SET comment_count = $count WHERE ID = '$post_id'");
+ $comment_count_cache[$post_id] = $count;
+ return true;
+}
+
function pingback($content, $post_ID) {
global $wp_version, $wpdb;
include_once (ABSPATH . WPINC . '/class-IXR.php');