diff --git src/wp-includes/comment.php src/wp-includes/comment.php
index c8984f0..1aaa9a0 100644
|
|
function delete_comment_meta($comment_id, $meta_key, $meta_value = '') { |
977 | 977 | * is true. |
978 | 978 | */ |
979 | 979 | function get_comment_meta($comment_id, $key = '', $single = false) { |
| 980 | global $in_comment_loop; |
| 981 | |
| 982 | if ( $in_comment_loop ) { |
| 983 | update_comment_meta_cache(); |
| 984 | } |
| 985 | |
980 | 986 | return get_metadata('comment', $comment_id, $key, $single); |
981 | 987 | } |
982 | 988 | |
983 | 989 | /** |
| 990 | * Update cache for comment meta in the current comment loop |
| 991 | * |
| 992 | * @since 4.2 |
| 993 | * |
| 994 | * @param object $wp_query Optional. A WP_Query instance. Defaults to the $wp_query global. |
| 995 | */ |
| 996 | function update_comment_meta_cache( $wp_query = null ) { |
| 997 | if ( ! $wp_query ) { |
| 998 | $wp_query = $GLOBALS['wp_query']; |
| 999 | } |
| 1000 | |
| 1001 | if ( $wp_query->comment_meta_cached ) { |
| 1002 | return; |
| 1003 | } |
| 1004 | |
| 1005 | $comment_ids = wp_list_pluck( $wp_query->comments, 'comment_ID' ); |
| 1006 | |
| 1007 | update_meta_cache( 'comment', $comment_ids ); |
| 1008 | |
| 1009 | $wp_query->comment_meta_cached = true; |
| 1010 | } |
| 1011 | |
| 1012 | /** |
984 | 1013 | * Update comment meta field based on comment ID. |
985 | 1014 | * |
986 | 1015 | * Use the $prev_value parameter to differentiate between meta fields with the |
diff --git src/wp-includes/query.php src/wp-includes/query.php
index cfb1e77..b3be057 100644
|
|
class WP_Query { |
1293 | 1293 | public $thumbnails_cached = false; |
1294 | 1294 | |
1295 | 1295 | /** |
| 1296 | * Set if comment meta has already been cached |
| 1297 | * |
| 1298 | * @since 4.2 |
| 1299 | * @access public |
| 1300 | * @var bool |
| 1301 | */ |
| 1302 | public $comment_meta_cached = false; |
| 1303 | |
| 1304 | /** |
1296 | 1305 | * Cached list of search stopwords. |
1297 | 1306 | * |
1298 | 1307 | * @since 3.7.0 |