In wp_list_comments(), update the comment meta cache when the comments derive from WP_Query and the new ->comment_meta_cached prop is false.

There are no uses of `wp_list_comments()` in Core where `$comments` are passed as the 2nd argument.

Adds unit tests.

Props wonderboymusic, bradt.
Fixes #16894.


git-svn-id: https://develop.svn.wordpress.org/trunk@33925 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Scott Taylor
2015-09-05 22:24:16 +00:00
parent 43340fe787
commit 542ac152fc
3 changed files with 79 additions and 0 deletions
+6
View File
@@ -2116,6 +2116,12 @@ function wp_list_comments( $args = array(), $comments = null ) {
} else {
$_comments = $wp_query->comments;
}
if ( ! $wp_query->comment_meta_cached ) {
$comment_ids = wp_list_pluck( $_comments, 'comment_ID' );
update_meta_cache( 'comment', $comment_ids );
$wp_query->comment_meta_cached = true;
}
}
if ( '' === $r['per_page'] && get_option('page_comments') )