Make WordPress Core


Ignore:
Timestamp:
10/20/2025 07:59:15 PM (3 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/src/wp-includes/pluggable.php

    r60698 r60989  
    126126        global $wpdb;
    127127
    128         update_meta_cache( 'user', $user_ids );
     128        $user_ids = array_unique( array_map( 'intval', $user_ids ), SORT_NUMERIC );
     129        wp_lazyload_user_meta( $user_ids );
    129130
    130131        $clean = _get_non_cached_ids( $user_ids, 'users' );
Note: See TracChangeset for help on using the changeset viewer.