From 30c49f8df6dbdd9cfc1f4e2a7fdf977dd70d3314 Mon Sep 17 00:00:00 2001 From: spacedmonkey Date: Fri, 6 Jan 2023 10:35:15 +0000 Subject: [PATCH] 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 --- wp-includes/class-wp-query.php | 3 +-- wp-includes/version.php | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/wp-includes/class-wp-query.php b/wp-includes/class-wp-query.php index 0f29f1f3a3..a6b105ef28 100644 --- a/wp-includes/class-wp-query.php +++ b/wp-includes/class-wp-query.php @@ -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 */ diff --git a/wp-includes/version.php b/wp-includes/version.php index 3ff2ff474a..b4bfeede8b 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -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.