From 7102240efe2e52f87487ead1949f6b3235cbed81 Mon Sep 17 00:00:00 2001 From: Boone Gorges Date: Thu, 30 Mar 2017 16:51:47 +0000 Subject: [PATCH] Invalidate term query caches when setting or deleting term relationships. Prior to 4.7, term relationships - as set by `wp_set_object_terms()` or `wp_remove_object_terms()` - did not affect the term query cache. The introduction of the 'object_ids' parameter in 4.7 means that the query cache must be aware of object-term relationships. As such, the 'last_changed' incrementor is now invalidated when term relationships are modified. This bug only reared its head when delaying term counting, because term counting performs its own term query cache invalidation. Props mboynes. Fixes #40306. Built from https://develop.svn.wordpress.org/trunk@40353 git-svn-id: http://core.svn.wordpress.org/trunk@40260 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/taxonomy.php | 2 ++ wp-includes/version.php | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/wp-includes/taxonomy.php b/wp-includes/taxonomy.php index 9ebc9d0d0b..94f36689fd 100644 --- a/wp-includes/taxonomy.php +++ b/wp-includes/taxonomy.php @@ -2282,6 +2282,7 @@ function wp_set_object_terms( $object_id, $terms, $taxonomy, $append = false ) { } wp_cache_delete( $object_id, $taxonomy . '_relationships' ); + wp_cache_delete( 'last_changed', 'terms' ); /** * Fires after an object's terms have been set. @@ -2376,6 +2377,7 @@ function wp_remove_object_terms( $object_id, $terms, $taxonomy ) { $deleted = $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->term_relationships WHERE object_id = %d AND term_taxonomy_id IN ($in_tt_ids)", $object_id ) ); wp_cache_delete( $object_id, $taxonomy . '_relationships' ); + wp_cache_delete( 'last_changed', 'terms' ); /** * Fires immediately after an object-term relationship is deleted. diff --git a/wp-includes/version.php b/wp-includes/version.php index fb29cc5c6e..a20de0c87a 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.8-alpha-40352'; +$wp_version = '4.8-alpha-40353'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.