mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 22:30:04 +00:00
Comments: Always lazily load comment meta.
In [34270] introduced lazy loading of comment meta. However, this was only in the context of `WP_Query`. Other parts of the codebase, like `WP_Comment_Query` did not lazily load comment meta. In this change, calls to `update_meta_cache` are now replaced with `wp_lazyload_comment_meta`, that instead of priming comment meta caches, just adds them to the queue to be primed it ever called. This results in far less database queries, as there a number of places where comment meta is being primed unnecessarily and never used. Adding everything to the comment meta queue, also means that if comment meta is used, that is all loaded in a single database / cache call. Follow on from [55671], [55747]. Props spacedmonkey, peterwilsoncc, flixos90, mukesh27. Fixes #57801. git-svn-id: https://develop.svn.wordpress.org/trunk@55749 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -2813,7 +2813,7 @@ class WP_Query {
|
||||
$comment_ids = $wpdb->get_col( $comments_request );
|
||||
wp_cache_add( $cache_key, $comment_ids, 'comment-queries' );
|
||||
}
|
||||
_prime_comment_caches( $comment_ids, false );
|
||||
_prime_comment_caches( $comment_ids );
|
||||
|
||||
// Convert to WP_Comment.
|
||||
/** @var WP_Comment[] */
|
||||
@@ -3372,7 +3372,7 @@ class WP_Query {
|
||||
$comment_ids = $wpdb->get_col( $comments_request );
|
||||
wp_cache_add( $comment_cache_key, $comment_ids, 'comment-queries' );
|
||||
}
|
||||
_prime_comment_caches( $comment_ids, false );
|
||||
_prime_comment_caches( $comment_ids );
|
||||
|
||||
// Convert to WP_Comment.
|
||||
/** @var WP_Comment[] */
|
||||
@@ -3487,11 +3487,6 @@ class WP_Query {
|
||||
}
|
||||
}
|
||||
|
||||
// If comments have been fetched as part of the query, make sure comment meta lazy-loading is set up.
|
||||
if ( ! empty( $this->comments ) ) {
|
||||
wp_queue_comments_for_comment_meta_lazyload( $this->comments );
|
||||
}
|
||||
|
||||
if ( ! $q['suppress_filters'] ) {
|
||||
/**
|
||||
* Filters the array of retrieved posts after they've been fetched and
|
||||
|
||||
Reference in New Issue
Block a user