Make WordPress Core

Changeset 33925


Ignore:
Timestamp:
09/05/2015 10:24:16 PM (9 years ago)
Author:
wonderboymusic
Message:

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.

Location:
trunk
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/comment-template.php

    r33919 r33925  
    21162116        } else {
    21172117            $_comments = $wp_query->comments;
     2118        }
     2119
     2120        if ( ! $wp_query->comment_meta_cached ) {
     2121            $comment_ids = wp_list_pluck( $_comments, 'comment_ID' );
     2122            update_meta_cache( 'comment', $comment_ids );
     2123            $wp_query->comment_meta_cached = true;
    21182124        }
    21192125    }
  • trunk/src/wp-includes/query.php

    r33891 r33925  
    12921292     */
    12931293     public $thumbnails_cached = false;
     1294
     1295    /**
     1296     * Set if comment meta has already been cached
     1297     *
     1298     * @since 4.4.0
     1299     * @access public
     1300     * @var bool
     1301     */
     1302     public $comment_meta_cached = false;
    12941303
    12951304    /**
Note: See TracChangeset for help on using the changeset viewer.