id summary reporter owner description type status priority milestone component version severity resolution keywords cc focuses 40306 Term cache isn't cleared completely when setting and removing object terms mboynes boonebgorges "This problem is easiest explained and understood through a unit test; see attached for that plus the patch fixing it. `wp_set_object_terms()` and `wp_remove_object_terms()` delete the object cache entry for the object ID in the group `{$taxonomy}_relationships`. However, `Term_Query`, which ultimately queries for those terms, has its own cache that doesn't get invalidated.`Term_Query`'s cache key depends on the `terms:last_changed` cache entry, so deleting that cache entry will invalidate the cache. This could/should be a bigger issue than it actually is. The reason it isn't is that the cache gets cleared incidentally via `wp_update_term_count_now()`, which performs [https://core.trac.wordpress.org/browser/tags/4.7.3/src/wp-includes/taxonomy.php#L2891 a pretty greedy cache clear]. If one is using an external object cache and disables term counting, the term relationship gets set when the default empty post is created on the ""Write"" screen and is never erased, and it will forever appear as though a post has no terms (until some other operation invalidates the `Term_Query` cache)." defect (bug) closed normal 4.7.4 Taxonomy 4.7 normal fixed reporter-feedback