Query: Improve WP_Query's cache key generation for taxonomy queries.

Modify how `WP_Query` determines whether a database query contains a taxonomy component and accounts for term changes when generating the cache key. This presents a stale cache been used under some circumstances.

Props Chouby, costdev, peterwilsoncc.
See #22176.


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


git-svn-id: http://core.svn.wordpress.org/trunk@53670 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Peter Wilson 2022-09-09 02:06:09 +00:00
parent b8f713ab09
commit 31c90342c9
2 changed files with 2 additions and 2 deletions

View File

@ -3094,7 +3094,7 @@ class WP_Query {
$key = md5( serialize( $cache_args ) . $new_request );
$last_changed = wp_cache_get_last_changed( 'posts' );
if ( ! empty( $this->tax_query->queried_terms ) ) {
if ( ! empty( $this->tax_query->queries ) ) {
$last_changed .= wp_cache_get_last_changed( 'terms' );
}

View File

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