More bonkers comment cache cleanup: toggle wp_defer_comment_counting() in wp_insert_post() and wp_insert_attachment(). Move the cache deletion in wp_update_comment_count_now() to before the get_post() call, so that the caches get deleted even if the post has already been deleted and the function returns early.

See #33875.


git-svn-id: https://develop.svn.wordpress.org/trunk@34158 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Scott Taylor
2015-09-15 00:57:48 +00:00
parent 8cb6843170
commit 95795c1301
2 changed files with 17 additions and 6 deletions
+4 -3
View File
@@ -1907,6 +1907,10 @@ function wp_update_comment_count_now($post_id) {
$post_id = (int) $post_id;
if ( !$post_id )
return false;
wp_cache_delete( 'comments-0', 'counts' );
wp_cache_delete( "comments-{$post_id}", 'counts' );
if ( !$post = get_post($post_id) )
return false;
@@ -1916,9 +1920,6 @@ function wp_update_comment_count_now($post_id) {
clean_post_cache( $post );
wp_cache_delete( 'comments-0', 'counts' );
wp_cache_delete( "comments-{$post_id}", 'counts' );
/**
* Fires immediately after a post's comment count is updated in the database.
*