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.



git-svn-id: https://develop.svn.wordpress.org/trunk@53309 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Jonny Harris
2022-04-29 12:34:35 +00:00
parent 34ecbc808c
commit 5866165adf
2 changed files with 78 additions and 0 deletions

View File

@@ -457,6 +457,14 @@ class WP_Term_Query {
"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_tree = $args['exclude_tree'];
$include = $args['include'];