Make WordPress Core

Opened 9 years ago

Closed 9 years ago

#7213 closed defect (bug) (fixed)

get_terms caching ignores filters

Reported by: filosofo Owned by:
Milestone: 2.6 Priority: normal
Severity: normal Version: 2.6
Component: General Keywords: has-patch wp_cache_set get_terms
Focuses: Cc:


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.

Attachments (1)

cache_setting.diff (771 bytes) - added by filosofo 9 years ago.

Download all attachments as: .zip

Change History (2)

#1 @ryan
9 years ago

  • Resolution set to fixed
  • Status changed from new to closed

(In [8225]) Account for term exclusion filter when creating cache key. Props filosofo. fixes #7213

Note: See TracTickets for help on using tickets.