From db603605ac3465185c6b07f9b0351f325c28f0e6 Mon Sep 17 00:00:00 2001 From: spacedmonkey Date: Thu, 3 Feb 2022 17:43:06 +0000 Subject: [PATCH] Taxonomy: Remove cache expiry limitation in WP_Term_Query. Remove the one day expiry limitation from query caches found in the `WP_Term_Qurery` class. Removing this limitation means that the caches will remain in object caching, as long as possible. Ensure that all term / taxonomy cache clear functions invalidate query caches, by deleting the last_changed value in the terms cache group. Props spacedmonkey, adamsilverstein, boonebgorges, tillkruess, dlh, flixos90. Fixes #54511. Built from https://develop.svn.wordpress.org/trunk@52669 git-svn-id: http://core.svn.wordpress.org/trunk@52258 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/class-wp-term-query.php | 4 ++-- wp-includes/taxonomy.php | 3 +++ wp-includes/version.php | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/wp-includes/class-wp-term-query.php b/wp-includes/class-wp-term-query.php index 226c623c9f..1583ed6ab6 100644 --- a/wp-includes/class-wp-term-query.php +++ b/wp-includes/class-wp-term-query.php @@ -775,7 +775,7 @@ class WP_Term_Query { } if ( empty( $terms ) ) { - wp_cache_add( $cache_key, array(), 'terms', DAY_IN_SECONDS ); + wp_cache_add( $cache_key, array(), 'terms' ); return array(); } @@ -880,7 +880,7 @@ class WP_Term_Query { } } - wp_cache_add( $cache_key, $terms, 'terms', DAY_IN_SECONDS ); + wp_cache_add( $cache_key, $terms, 'terms' ); if ( 'all' === $_fields || 'all_with_object_id' === $_fields ) { $terms = $this->populate_terms( $terms ); diff --git a/wp-includes/taxonomy.php b/wp-includes/taxonomy.php index fbfef11ce8..201864cbc1 100644 --- a/wp-includes/taxonomy.php +++ b/wp-includes/taxonomy.php @@ -3518,6 +3518,8 @@ function clean_object_term_cache( $object_ids, $object_type ) { } } + wp_cache_delete( 'last_changed', 'terms' ); + /** * Fires after the object term cache has been cleaned. * @@ -3610,6 +3612,7 @@ function clean_term_cache( $ids, $taxonomy = '', $clean_taxonomy = true ) { function clean_taxonomy_cache( $taxonomy ) { wp_cache_delete( 'all_ids', $taxonomy ); wp_cache_delete( 'get', $taxonomy ); + wp_cache_delete( 'last_changed', 'terms' ); // Regenerate cached hierarchy. delete_option( "{$taxonomy}_children" ); diff --git a/wp-includes/version.php b/wp-includes/version.php index 29bba841e1..90c022bf37 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.0-alpha-52668'; +$wp_version = '6.0-alpha-52669'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.