Taxonomy: Increase cache hits in `WP_Term_Query` when using include and exclude parameters.

Ensure that empty values of include and exclude passed to the parameters of `WP_Term_Query`, reused existing caches by 
resetting values to an empty array. 

Props Spacedmonkey, peterwilsoncc, hellofromtonya.
Follow-up to [52970].
See #55352.


Built from https://develop.svn.wordpress.org/trunk@53309


git-svn-id: http://core.svn.wordpress.org/trunk@52898 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
spacedmonkey 2022-04-29 12:36:13 +00:00
parent e9850e7225
commit b00e2a0e89
2 changed files with 9 additions and 1 deletions

View File

@ -457,6 +457,14 @@ class WP_Term_Query {
"tt.taxonomy IN ('" . implode( "', '", array_map( 'esc_sql', $taxonomies ) ) . "')"; "tt.taxonomy IN ('" . implode( "', '", array_map( 'esc_sql', $taxonomies ) ) . "')";
} }
if ( empty( $args['exclude'] ) ) {
$args['exclude'] = array();
}
if ( empty( $args['include'] ) ) {
$args['include'] = array();
}
$exclude = $args['exclude']; $exclude = $args['exclude'];
$exclude_tree = $args['exclude_tree']; $exclude_tree = $args['exclude_tree'];
$include = $args['include']; $include = $args['include'];

View File

@ -16,7 +16,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '6.0-beta3-53308'; $wp_version = '6.0-beta3-53309';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.