From afcc5e64f487335daa33fc93f180877670d0be60 Mon Sep 17 00:00:00 2001 From: spacedmonkey Date: Thu, 31 Mar 2022 10:06:01 +0000 Subject: [PATCH] Taxonomy: Improve performance by taxonomy queries by adding a limitting requested terms. Add a limit to the number of terms requested in taxonomy queries. This improves the performance of the query and the likelihood of hitting an existing term query cache. Props Spacedmonkey, peterwilsoncc, flixos90. Fixes #55360. Built from https://develop.svn.wordpress.org/trunk@53037 git-svn-id: http://core.svn.wordpress.org/trunk@52626 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/class-wp-tax-query.php | 4 ++++ wp-includes/version.php | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/wp-includes/class-wp-tax-query.php b/wp-includes/class-wp-tax-query.php index eb4b7849e2..862a28f768 100644 --- a/wp-includes/class-wp-tax-query.php +++ b/wp-includes/class-wp-tax-query.php @@ -637,6 +637,10 @@ class WP_Tax_Query { break; } + if ( ! is_taxonomy_hierarchical( $query['taxonomy'] ) ) { + $args['number'] = count( $terms ); + } + $term_query = new WP_Term_Query(); $term_list = $term_query->query( $args ); diff --git a/wp-includes/version.php b/wp-includes/version.php index cea5b3b8af..b271e6f1bc 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.0-alpha-53036'; +$wp_version = '6.0-alpha-53037'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.