get_terms caching ignores filters
|Reported by:||filosofo||Owned by:|
|Component:||General||Keywords:||has-patch wp_cache_set get_terms|
get_terms sets the cache for a terms query, serializing the default query args and their values as the cache key, so that in theory there will be different cache keys for each get_terms query.
However, get_terms calls wp_cache_set before the 'list_terms_exclusions' filter is called, meaning that anything done by those callbacks on that filter will not result in distinct cache keys.
My patch serializes the callbacks for 'list_terms_exclusions', if there are any, and adds it to the cache key.
I looked grepped through the rest of core WP and could not find any other similar situations, i.e. situations where the cache is set before filters are called.
BTW, this bug was difficult to track down and so might be difficult to reproduce, because a number of different situations cause the cache to be flushed, meaning that the bug's appearance is sporadic.