Make WordPress Core


Ignore:
Timestamp:
10/20/2025 07:59:15 PM (10 months ago)
Author:
spacedmonkey
Message:

Users: Lazy-load user meta.

In [36566], a framework for lazily loading metadata was introduced, initially supporting term and comment meta. This commit extends that support to user meta.

User meta can contain a large amount of data that is not always needed, particularly on the front end. To address this, cache_users() now calls the new function wp_lazyload_user_meta(). This function accepts an array of user IDs and adds them to the queue of metadata to be lazily loaded.

Follows on from [55671], [55747].

Props spacedmonkey, westonruter.
Fixes #63021.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/query/cacheResults.php

    r60729 r60989  
    19831983                $num_loop_queries = get_num_queries() - $start_loop_queries;
    19841984                /*
    1985                  * Two expected queries:
    1986                  * 1: User meta data,
    1987                  * 2: User data.
     1985                 * One expected query:
     1986                 * 1: User data.
    19881987                 */
    1989                 $this->assertSame( 2, $num_loop_queries, 'Unexpected number of queries while initializing the loop.' );
     1988                $this->assertSame( 1, $num_loop_queries, 'Unexpected number of queries while initializing the loop.' );
    19901989
    19911990                $start_author_queries = get_num_queries();
Note: See TracChangeset for help on using the changeset viewer.