diff --git a/wp-includes/class-wp-query.php b/wp-includes/class-wp-query.php index f555b1bb18..efa7dc8db3 100644 --- a/wp-includes/class-wp-query.php +++ b/wp-includes/class-wp-query.php @@ -3434,9 +3434,11 @@ class WP_Query { */ public function the_post() { global $post; + if ( ! $this->in_the_loop ) { update_post_author_caches( $this->posts ); } + $this->in_the_loop = true; if ( -1 == $this->current_post ) { // Loop has just started. diff --git a/wp-includes/pluggable.php b/wp-includes/pluggable.php index d95f26d20d..bd80946c0c 100644 --- a/wp-includes/pluggable.php +++ b/wp-includes/pluggable.php @@ -143,6 +143,7 @@ if ( ! function_exists( 'cache_users' ) ) : $list = implode( ',', $clean ); $users = $wpdb->get_results( "SELECT * FROM $wpdb->users WHERE ID IN ($list)" ); + foreach ( $users as $user ) { update_user_caches( $user ); } diff --git a/wp-includes/post.php b/wp-includes/post.php index fb69b71ee5..9b3b4bc28c 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -7424,11 +7424,11 @@ function clean_post_cache( $post ) { } /** - * Calls major cache updating functions for list of Post objects. + * Updates post, term, and metadata caches for a list of post objects. * * @since 1.5.0 * - * @param WP_Post[] $posts Array of Post objects + * @param WP_Post[] $posts Array of post objects (passed by reference). * @param string $post_type Optional. Post type. Default 'post'. * @param bool $update_term_cache Optional. Whether to update the term cache. Default true. * @param bool $update_meta_cache Optional. Whether to update the meta cache. Default true. @@ -7475,21 +7475,22 @@ function update_post_caches( &$posts, $post_type = 'post', $update_term_cache = } /** - * Prime post author user caches. + * Updates post author user caches for a list of post objects. * * @since 6.1.0 * - * @param WP_Post[] $posts Array of Post objects + * @param WP_Post[] $posts Array of post objects. */ function update_post_author_caches( $posts ) { $author_ids = wp_list_pluck( $posts, 'post_author' ); $author_ids = array_map( 'absint', $author_ids ); $author_ids = array_unique( array_filter( $author_ids ) ); + cache_users( $author_ids ); } /** - * Updates metadata cache for list of post IDs. + * Updates metadata cache for a list of post IDs. * * Performs SQL query to retrieve the metadata for the post IDs and updates the * metadata cache for the posts. Therefore, the functions, which call this diff --git a/wp-includes/version.php b/wp-includes/version.php index 48b83b5009..b50b61cb73 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.1-alpha-53482'; +$wp_version = '6.1-alpha-53483'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.