Ticket #4740: 4740.diff
| File 4740.diff, 1.3 KB (added by , 19 years ago) |
|---|
-
wp-includes/comment.php
500 500 $post_id = (int) $post_id; 501 501 if ( !$post_id ) 502 502 return false; 503 $count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_post_ID = '$post_id' AND comment_approved = '1'"); 504 $wpdb->query("UPDATE $wpdb->posts SET comment_count = $count WHERE ID = '$post_id'"); 505 $comment_count_cache[$post_id] = $count; 503 if ( !$post = get_post($post_id) ) 504 return false; 506 505 507 $post = get_post($post_id); 506 $old = (int) $post->comment_count; 507 $new = (int) $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_post_ID = '$post_id' AND comment_approved = '1'"); 508 $wpdb->query("UPDATE $wpdb->posts SET comment_count = '$new' WHERE ID = '$post_id'"); 509 $comment_count_cache[$post_id] = $new; 510 508 511 if ( 'page' == $post->post_type ) 509 512 clean_page_cache( $post_id ); 510 513 else 511 514 clean_post_cache( $post_id ); 512 515 513 do_action('edit_post', $post_id); 516 do_action('wp_update_comment_count', $post_id, $new, $old); 517 do_action('edit_post', $post_id, $post); 514 518 515 519 return true; 516 520 } … … 816 820 wp_cache_add($comment->comment_ID, $comment, 'comment'); 817 821 } 818 822 819 ?> 820 No newline at end of file 823 ?>