[wp-trac] [WordPress Trac] #34533: Term splitting in `get_term()` can have unexpected effects
WordPress Trac
noreply at wordpress.org
Wed Nov 4 02:14:24 UTC 2015
#34533: Term splitting in `get_term()` can have unexpected effects
--------------------------+--------------------
Reporter: dlh | Owner:
Type: defect (bug) | Status: new
Priority: high | Milestone: 4.4
Component: Taxonomy | Version: trunk
Severity: normal | Resolution:
Keywords: has-patch | Focuses:
--------------------------+--------------------
Comment (by boonebgorges):
I realized after writing the first patch that there could be further cache
confusion when there are shared terms. Calling `get_term( $term_id, 'foo'
)` will populate the cache with the `foo` term; if it's shared with
taxonomy `bar`, then `get_term( $term_id, 'bar' )` will incorrectly fetch
the `foo` term from the cache. [attachment:34533.2.diff] fixes this.
There is still the possibility for cache entanglement. Specifically, if
you don't specify a `$taxonomy` in `get_term()`, then you're going to get
whatever's in the cache, and if your `$term_id` is shared between
taxonomies, what's in the cache may not be what you wanted. There's not
really anything we can do about this, and I think it's reasonable to say
that if you want support for the new `get_term( $term_id )` syntax, that
you need to have run the term-splitting routine in order to guarantee
coherent caching. (The only other alternative, without ripping the whole
thing out, is to skip single-term caching when
'finished_splitting_shared_terms' is not true. Pretty ugly.)
Cache confusion for single-term caches would be much harder to deal with
if we were using those caches in places like `get_terms()`. Luckily, we
are not doing this at the moment, but it's going to be an unpleasant
hurdle when we finally do.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/34533#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list