[wp-trac] [WordPress Trac] #45232: get_object_term_cache() returns an empty array

WordPress Trac noreply at wordpress.org
Tue Oct 30 22:15:35 UTC 2018

#45232: get_object_term_cache() returns an empty array
 Reporter:  sebastienserre     |       Owner:  (none)
     Type:  defect (bug)       |      Status:  new
 Priority:  normal             |   Milestone:  Awaiting Review
Component:  Taxonomy           |     Version:  5.0
 Severity:  normal             |  Resolution:
 Keywords:  reporter-feedback  |     Focuses:
Changes (by boonebgorges):

 * keywords:  dev-feedback has-patch => reporter-feedback


 Hi @sebastienserre - Thanks for the ticket and for the patch.

 WP intentionally caches empty arrays in cases where an object doesn't have
 any terms in a given taxonomy. This helps us to avoid excess database
 queries when, for example, you're fetching the `post_tag` terms for post
 `123`, but `123` doesn't have any terms from `post_tag`. Your suggested
 change will break this behavior, so that term queries that result in empty
 arrays will never be cached.

 If `get_term_object_cache()` is returning an empty array, it suggests that
 there's a problem further up the stack. The most likely problem is that
 the `{$taxonomy}_relationships` cache is not being properly invalidated
 somewhere in your setup.

 Are you able to reproduce your bug on a stock installation of WordPress,
 with no additional plugins and a clean database? Does it occur only with a
 persistent caching backend (Memcached, etc)? Can you provide steps to

Ticket URL: <https://core.trac.wordpress.org/ticket/45232#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform

More information about the wp-trac mailing list