From cda77232fe255da611bae599ca1f8eb5cee09cb6 Mon Sep 17 00:00:00 2001 From: Andrew Nacin Date: Sun, 14 Jun 2015 19:20:12 +0000 Subject: [PATCH] Update comment caches in WP_Comment_Query, rather than comments template. props dd32. fixes #31081. git-svn-id: https://develop.svn.wordpress.org/trunk@32769 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/comment-template.php | 1 - src/wp-includes/comment.php | 3 +++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/wp-includes/comment-template.php b/src/wp-includes/comment-template.php index a04f9bef89..b8d2e43357 100644 --- a/src/wp-includes/comment-template.php +++ b/src/wp-includes/comment-template.php @@ -1202,7 +1202,6 @@ function comments_template( $file = '/comments.php', $separate_comments = false $wp_query->comments = apply_filters( 'comments_array', $comments, $post->ID ); $comments = &$wp_query->comments; $wp_query->comment_count = count($wp_query->comments); - update_comment_cache($wp_query->comments); if ( $separate_comments ) { $wp_query->comments_by_type = separate_comments($comments); diff --git a/src/wp-includes/comment.php b/src/wp-includes/comment.php index a58bbfe20b..039d529939 100644 --- a/src/wp-includes/comment.php +++ b/src/wp-includes/comment.php @@ -893,6 +893,9 @@ class WP_Comment_Query { $comments = apply_filters_ref_array( 'the_comments', array( $results, &$this ) ); wp_cache_add( $cache_key, $comments, 'comment' ); + if ( '*' === $fields ) { + update_comment_cache( $comments ); + } $this->comments = $comments; return $this->comments;