Changeset 53483
- Timestamp:
- 06/10/2022 03:15:07 PM (2 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-query.php
r53482 r53483 3435 3435 public function the_post() { 3436 3436 global $post; 3437 3437 3438 if ( ! $this->in_the_loop ) { 3438 3439 update_post_author_caches( $this->posts ); 3439 3440 } 3441 3440 3442 $this->in_the_loop = true; 3441 3443 -
trunk/src/wp-includes/pluggable.php
r53482 r53483 144 144 145 145 $users = $wpdb->get_results( "SELECT * FROM $wpdb->users WHERE ID IN ($list)" ); 146 146 147 foreach ( $users as $user ) { 147 148 update_user_caches( $user ); -
trunk/src/wp-includes/post.php
r53482 r53483 7425 7425 7426 7426 /** 7427 * Calls major cache updating functions for list of Post objects.7427 * Updates post, term, and metadata caches for a list of post objects. 7428 7428 * 7429 7429 * @since 1.5.0 7430 7430 * 7431 * @param WP_Post[] $posts Array of Post objects7431 * @param WP_Post[] $posts Array of post objects (passed by reference). 7432 7432 * @param string $post_type Optional. Post type. Default 'post'. 7433 7433 * @param bool $update_term_cache Optional. Whether to update the term cache. Default true. … … 7476 7476 7477 7477 /** 7478 * Prime post author user caches.7478 * Updates post author user caches for a list of post objects. 7479 7479 * 7480 7480 * @since 6.1.0 7481 7481 * 7482 * @param WP_Post[] $posts Array of Post objects7482 * @param WP_Post[] $posts Array of post objects. 7483 7483 */ 7484 7484 function update_post_author_caches( $posts ) { … … 7486 7486 $author_ids = array_map( 'absint', $author_ids ); 7487 7487 $author_ids = array_unique( array_filter( $author_ids ) ); 7488 7488 7489 cache_users( $author_ids ); 7489 7490 } 7490 7491 7491 7492 /** 7492 * Updates metadata cache for list of post IDs.7493 * Updates metadata cache for a list of post IDs. 7493 7494 * 7494 7495 * Performs SQL query to retrieve the metadata for the post IDs and updates the -
trunk/tests/phpunit/tests/post/updatePostCache.php
r53042 r53483 1 1 <?php 2 2 /** 3 * Test ` wp_update_cache()`.3 * Test `update_post_cache()`. 4 4 * 5 5 * @package WordPress … … 7 7 8 8 /** 9 * Test class for ` wp_update_cache()`.9 * Test class for `update_post_cache()`. 10 10 * 11 11 * @group post … … 19 19 * Post IDs from the shared fixture. 20 20 * 21 * @var array21 * @var int[] 22 22 */ 23 23 public static $post_ids; -
trunk/tests/phpunit/tests/query.php
r53482 r53483 622 622 623 623 /** 624 * @ticket 55716625 */626 public function test_prime_user_cache() {627 $action = new MockAction();628 add_filter( 'update_user_metadata_cache', array( $action, 'filter' ), 10, 2 );629 $user_ids = array();630 $count = 5;631 for ( $i = 0; $i < $count; $i ++ ) {632 $user_ids[ $i ] = self::factory()->user->create();633 self::factory()->post->create(634 array(635 'post_type' => 'post',636 'post_author' => $user_ids[ $i ],637 )638 );639 }640 641 $q = new WP_Query(642 array(643 'post_type' => 'post',644 'posts_per_page' => $count,645 )646 );647 while ( $q->have_posts() ) {648 $q->the_post();649 }650 651 $args = $action->get_args();652 $last_args = end( $args );653 $this->assertSameSets( $user_ids, $last_args[1], 'Ensure that user ids are primed' );654 }655 656 /**657 624 * @ticket 35601 658 625 */
Note: See TracChangeset
for help on using the changeset viewer.