WordPress.org

Make WordPress Core

Ticket #16894: 16894.diff

File 16894.diff, 1.6 KB (added by bradt, 5 years ago)
  • wp-includes/comment.php

    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 = '') { 
    977977 *  is true.
    978978 */
    979979function 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
    980986        return get_metadata('comment', $comment_id, $key, $single);
    981987}
    982988
    983989/**
     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 */
     996function 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/**
    9841013 * Update comment meta field based on comment ID.
    9851014 *
    9861015 * Use the $prev_value parameter to differentiate between meta fields with the
  • wp-includes/query.php

    diff --git src/wp-includes/query.php src/wp-includes/query.php
    index cfb1e77..b3be057 100644
    class WP_Query { 
    12931293         public $thumbnails_cached = false;
    12941294
    12951295        /**
     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        /**
    12961305         * Cached list of search stopwords.
    12971306         *
    12981307         * @since 3.7.0