diff --git src/wp-includes/class-wp-comment-query.php src/wp-includes/class-wp-comment-query.php
index ec35a2a..b7f210a 100644
|
|
class WP_Comment_Query { |
161 | 161 | * @type array $type__in Include comments from a given array of comment types. Default empty. |
162 | 162 | * @type array $type__not_in Exclude comments from a given array of comment types. Default empty. |
163 | 163 | * @type int $user_id Include comments for a specific user ID. Default empty. |
| 164 | * @type bool $update_comment_meta_cache Whether to prime the metadata cache for found comments. |
| 165 | * Default: true. |
164 | 166 | * } |
165 | 167 | */ |
166 | 168 | public function __construct( $query = '' ) { |
… |
… |
class WP_Comment_Query { |
201 | 203 | 'meta_value' => '', |
202 | 204 | 'meta_query' => '', |
203 | 205 | 'date_query' => null, // See WP_Date_Query |
| 206 | 'update_comment_meta_cache' => true, |
204 | 207 | ); |
205 | 208 | |
206 | 209 | if ( ! empty( $query ) ) { |
… |
… |
class WP_Comment_Query { |
698 | 701 | |
699 | 702 | wp_cache_add( $cache_key, $comments, 'comment' ); |
700 | 703 | if ( '*' === $fields ) { |
701 | | update_comment_cache( $comments ); |
| 704 | update_comment_cache( $comments, $this->query_vars['update_comment_meta_cache'] ); |
702 | 705 | } |
703 | 706 | |
704 | 707 | $this->comments = $comments; |
diff --git src/wp-includes/comment-functions.php src/wp-includes/comment-functions.php
index 08ddfd2..eeb4499 100644
|
|
function clean_comment_cache($ids) { |
2357 | 2357 | * cache using the comment group with the key using the ID of the comments. |
2358 | 2358 | * |
2359 | 2359 | * @since 2.3.0 |
| 2360 | * @since 4.4.0 Introduced the `$update_meta_cache` parameter. |
2360 | 2361 | * |
2361 | 2362 | * @param array $comments Array of comment row objects |
2362 | 2363 | */ |
2363 | | function update_comment_cache($comments) { |
| 2364 | function update_comment_cache( $comments, $update_meta_cache = true ) { |
2364 | 2365 | foreach ( (array) $comments as $comment ) |
2365 | 2366 | wp_cache_add($comment->comment_ID, $comment, 'comment'); |
| 2367 | |
| 2368 | if ( $update_meta_cache ) { |
| 2369 | $comment_ids = wp_list_pluck( $comments, 'comment_ID' ); |
| 2370 | update_meta_cache( 'comment', $comment_ids ); |
| 2371 | } |
2366 | 2372 | } |
2367 | 2373 | |
2368 | 2374 | // |