Skip to content

Commit c6c922c

Browse files
committed
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. git-svn-id: https://develop.svn.wordpress.org/trunk@61038 602fd350-edb4-49c9-b593-d223f7449a82
1 parent ea2329b commit c6c922c

File tree

8 files changed

+9
-121
lines changed

8 files changed

+9
-121
lines changed

src/wp-includes/class-wp-metadata-lazyloader.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,6 @@ public function __construct() {
6565
'filter' => 'get_blog_metadata',
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
}
7470

src/wp-includes/pluggable.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,7 @@ function get_user_by( $field, $value ) {
125125
function cache_users( $user_ids ) {
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' );
132131

src/wp-includes/user.php

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1310,21 +1310,6 @@ function update_user_meta( $user_id, $meta_key, $meta_value, $prev_value = '' )
13101310
return update_metadata( 'user', $user_id, $meta_key, $meta_value, $prev_value );
13111311
}
13121312

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 );
1326-
}
1327-
13281313
/**
13291314
* Counts number of users who have each of the user roles.
13301315
*

tests/phpunit/includes/abstract-testcase.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,6 @@ protected function reset_lazyload_queue() {
305305
$lazyloader->reset_queue( 'term' );
306306
$lazyloader->reset_queue( 'comment' );
307307
$lazyloader->reset_queue( 'blog' );
308-
$lazyloader->reset_queue( 'user' );
309308
}
310309

311310
/**

tests/phpunit/tests/post/updatePostAuthorCaches.php

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -67,28 +67,6 @@ public function test_update_post_author_caches() {
6767
$q->the_post();
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 );
9472

tests/phpunit/tests/query/cacheResults.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1982,10 +1982,11 @@ public function test_author_cache_warmed_by_the_loop( $fields ) {
19821982
$query_1->the_post();
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();
19911992
get_user_by( 'ID', self::$author_id );

tests/phpunit/tests/query/thePost.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -265,10 +265,10 @@ public function test_the_loop_primes_the_author_cache( $fields, $expected_querie
265265
*/
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
}
274274

tests/phpunit/tests/user/lazyLoadMeta.php

Lines changed: 0 additions & 70 deletions
This file was deleted.

0 commit comments

Comments
 (0)