Pass post_type to clean_post_cache() instead of attempting to fetch a post object since the post may have been deleted.

Props leewillis77
see #19690


git-svn-id: https://develop.svn.wordpress.org/trunk@20423 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren
2012-04-10 16:09:44 +00:00
parent 69eca59eba
commit 27592057cd
4 changed files with 65 additions and 82 deletions
+1 -4
View File
@@ -1583,10 +1583,7 @@ function wp_update_comment_count_now($post_id) {
$new = (int) $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_approved = '1'", $post_id) );
$wpdb->update( $wpdb->posts, array('comment_count' => $new), array('ID' => $post_id) );
if ( 'page' == $post->post_type )
clean_page_cache( $post_id );
else
clean_post_cache( $post_id );
clean_post_cache( $post_id, $post->post_type );
do_action('wp_update_comment_count', $post_id, $new, $old);
do_action('edit_post', $post_id, $post);