Query: Stop priming posts twice in WP_Query.

Part revert of [54352]. In cases where queries are not split, then it results in priming posts that are already loaded resulting in a superfluous database query. 

Props spacedmonkey, flixos90, peterwilsoncc.
Fixes #57373.
Built from https://develop.svn.wordpress.org/trunk@55035


git-svn-id: http://core.svn.wordpress.org/trunk@54568 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
spacedmonkey 2023-01-06 10:35:15 +00:00
parent df12521451
commit 30c49f8df6
2 changed files with 2 additions and 3 deletions

View File

@ -3476,8 +3476,7 @@ class WP_Query {
$this->posts = array_map( 'get_post', $this->posts );
if ( $q['cache_results'] ) {
$post_ids = wp_list_pluck( $this->posts, 'ID' );
_prime_post_caches( $post_ids, $q['update_post_term_cache'], $q['update_post_meta_cache'] );
update_post_caches( $this->posts, $post_type, $q['update_post_term_cache'], $q['update_post_meta_cache'] );
}
/** @var WP_Post */

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.2-alpha-55034';
$wp_version = '6.2-alpha-55035';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.