Changeset 60989
- Timestamp:
- 10/20/2025 07:59:15 PM (5 weeks ago)
- Location:
- trunk
- Files:
-
- 1 added
- 7 edited
-
src/wp-includes/class-wp-metadata-lazyloader.php (modified) (1 diff)
-
src/wp-includes/pluggable.php (modified) (1 diff)
-
src/wp-includes/user.php (modified) (1 diff)
-
tests/phpunit/includes/abstract-testcase.php (modified) (1 diff)
-
tests/phpunit/tests/post/updatePostAuthorCaches.php (modified) (1 diff)
-
tests/phpunit/tests/query/cacheResults.php (modified) (1 diff)
-
tests/phpunit/tests/query/thePost.php (modified) (1 diff)
-
tests/phpunit/tests/user/lazyLoadMeta.php (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-metadata-lazyloader.php
r55747 r60989 64 64 'blog' => array( 65 65 'filter' => 'get_blog_metadata', 66 'callback' => array( $this, 'lazyload_meta_callback' ), 67 ), 68 'user' => array( 69 'filter' => 'get_user_metadata', 66 70 'callback' => array( $this, 'lazyload_meta_callback' ), 67 71 ), -
trunk/src/wp-includes/pluggable.php
r60698 r60989 126 126 global $wpdb; 127 127 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 ); 129 130 130 131 $clean = _get_non_cached_ids( $user_ids, 'users' ); -
trunk/src/wp-includes/user.php
r60981 r60989 1319 1319 function update_user_meta( $user_id, $meta_key, $meta_value, $prev_value = '' ) { 1320 1320 return update_metadata( 'user', $user_id, $meta_key, $meta_value, $prev_value ); 1321 } 1322 1323 /** 1324 * Queue user meta for lazy-loading. 1325 * 1326 * @since 6.9.0 1327 * 1328 * @param int[] $user_ids List of user IDs. 1329 */ 1330 function wp_lazyload_user_meta( array $user_ids ) { 1331 if ( empty( $user_ids ) ) { 1332 return; 1333 } 1334 $lazyloader = wp_metadata_lazyloader(); 1335 $lazyloader->queue_objects( 'user', $user_ids ); 1321 1336 } 1322 1337 -
trunk/tests/phpunit/includes/abstract-testcase.php
r60298 r60989 304 304 $lazyloader->reset_queue( 'comment' ); 305 305 $lazyloader->reset_queue( 'blog' ); 306 $lazyloader->reset_queue( 'user' ); 306 307 } 307 308 -
trunk/tests/phpunit/tests/post/updatePostAuthorCaches.php
r53483 r60989 68 68 } 69 69 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 70 92 $args = $action->get_args(); 71 93 $last_args = end( $args ); -
trunk/tests/phpunit/tests/query/cacheResults.php
r60729 r60989 1983 1983 $num_loop_queries = get_num_queries() - $start_loop_queries; 1984 1984 /* 1985 * Two expected queries: 1986 * 1: User meta data, 1987 * 2: User data. 1985 * One expected query: 1986 * 1: User data. 1988 1987 */ 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.' ); 1990 1989 1991 1990 $start_author_queries = get_num_queries(); -
trunk/tests/phpunit/tests/query/thePost.php
r59993 r60989 266 266 public function data_the_loop_fields() { 267 267 return array( 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),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 ), 272 272 ); 273 273 }
Note: See TracChangeset
for help on using the changeset viewer.