Make WordPress Core


Ignore:
Timestamp:
05/11/2023 12:25:51 PM (10 months ago)
Author:
spacedmonkey
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-comments-list-table.php

    r55732 r55749  
    166166
    167167        if ( is_array( $_comments ) ) {
    168             update_comment_cache( $_comments );
    169 
    170168            $this->items       = array_slice( $_comments, 0, $comments_per_page );
    171169            $this->extra_items = array_slice( $_comments, $comments_per_page );
Note: See TracChangeset for help on using the changeset viewer.