Make WordPress Core

Changeset 61038


Ignore:
Timestamp:
10/21/2025 03:57:16 PM (5 weeks ago)
Author:
davidbaumwald
Message:

Users: Revert Lazy-load user meta.

With [60915] reverted, this changeset is also being reverted to resolve test failures due to common code.

Reverts [60989].

Follow-up to [61037].

Props jorbin, ellatrix, spacedmonkey.
See #63021, #58001.

Location:
trunk
Files:
1 deleted
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-metadata-lazyloader.php

    r60989 r61038  
    6666                'callback' => array( $this, 'lazyload_meta_callback' ),
    6767            ),
    68             'user'    => array(
    69                 'filter'   => 'get_user_metadata',
    70                 'callback' => array( $this, 'lazyload_meta_callback' ),
    71             ),
    7268        );
    7369    }
  • trunk/src/wp-includes/pluggable.php

    r61010 r61038  
    126126        global $wpdb;
    127127
    128         $user_ids = array_unique( array_map( 'intval', $user_ids ), SORT_NUMERIC );
    129         wp_lazyload_user_meta( $user_ids );
     128        update_meta_cache( 'user', $user_ids );
    130129
    131130        $clean = _get_non_cached_ids( $user_ids, 'users' );
  • trunk/src/wp-includes/user.php

    r60996 r61038  
    13091309function update_user_meta( $user_id, $meta_key, $meta_value, $prev_value = '' ) {
    13101310    return update_metadata( 'user', $user_id, $meta_key, $meta_value, $prev_value );
    1311 }
    1312 
    1313 /**
    1314  * Queue user meta for lazy-loading.
    1315  *
    1316  * @since 6.9.0
    1317  *
    1318  * @param int[] $user_ids List of user IDs.
    1319  */
    1320 function wp_lazyload_user_meta( array $user_ids ) {
    1321     if ( empty( $user_ids ) ) {
    1322         return;
    1323     }
    1324     $lazyloader = wp_metadata_lazyloader();
    1325     $lazyloader->queue_objects( 'user', $user_ids );
    13261311}
    13271312
  • trunk/tests/phpunit/includes/abstract-testcase.php

    r61008 r61038  
    306306        $lazyloader->reset_queue( 'comment' );
    307307        $lazyloader->reset_queue( 'blog' );
    308         $lazyloader->reset_queue( 'user' );
    309308    }
    310309
  • trunk/tests/phpunit/tests/post/updatePostAuthorCaches.php

    r60989 r61038  
    6868        }
    6969
    70         $this->assertSame( 0, $action->get_call_count(), 'Ensure that user meta are not primed' );
    71     }
    72 
    73     /**
    74      * @ticket 63021
    75      */
    76     public function test_update_post_author_caches_force_load_meta() {
    77         $action = new MockAction();
    78         add_filter( 'update_user_metadata_cache', array( $action, 'filter' ), 10, 2 );
    79 
    80         $q = new WP_Query(
    81             array(
    82                 'post_type'      => 'post',
    83                 'posts_per_page' => self::$post_author_count,
    84             )
    85         );
    86 
    87         while ( $q->have_posts() ) {
    88             $q->the_post();
    89             get_the_author_meta(); // Force loading of author meta.
    90         }
    91 
    9270        $args      = $action->get_args();
    9371        $last_args = end( $args );
  • trunk/tests/phpunit/tests/query/cacheResults.php

    r60989 r61038  
    19831983        $num_loop_queries = get_num_queries() - $start_loop_queries;
    19841984        /*
    1985          * One expected query:
    1986          * 1: User data.
     1985         * Two expected queries:
     1986         * 1: User meta data,
     1987         * 2: User data.
    19871988         */
    1988         $this->assertSame( 1, $num_loop_queries, 'Unexpected number of queries while initializing the loop.' );
     1989        $this->assertSame( 2, $num_loop_queries, 'Unexpected number of queries while initializing the loop.' );
    19891990
    19901991        $start_author_queries = get_num_queries();
  • trunk/tests/phpunit/tests/query/thePost.php

    r60989 r61038  
    266266    public function data_the_loop_fields() {
    267267        return array(
    268             'all fields'                => array( 'all', 1 ),
    269             'all fields (empty fields)' => array( '', 1 ),
    270             'post IDs'                  => array( 'ids', 3 ),
    271             'post ids and parent'       => array( 'id=>parent', 3 ),
     268            'all fields'                => array( 'all', 2 ),
     269            'all fields (empty fields)' => array( '', 2 ),
     270            'post IDs'                  => array( 'ids', 4 ),
     271            'post ids and parent'       => array( 'id=>parent', 4 ),
    272272        );
    273273    }
Note: See TracChangeset for help on using the changeset viewer.