[wp-trac] [WordPress Trac] #21760: get_term_by() calls are not cached
WordPress Trac
noreply at wordpress.org
Sat Jul 5 15:10:28 UTC 2014
#21760: get_term_by() calls are not cached
------------------------------+-----------------------------
Reporter: wonderboymusic | Owner: wonderboymusic
Type: enhancement | Status: assigned
Priority: normal | Milestone: 4.0
Component: Taxonomy | Version: 2.3
Severity: normal | Resolution:
Keywords: has-patch commit | Focuses:
------------------------------+-----------------------------
Comment (by tollmanz):
[https://core.trac.wordpress.org/attachment/ticket/21760/21760.10.diff
21760.10.diff] iterates on this patch by adding /updating the following:
* I found a slight bug in the `get_term_by()` adds the `$term` object to
the cache. The values were cached ''before'' the `$term` object was run
through the sanitization function. The sanitization function converts ints
to strings. Therefore, a term grabbed from the cache would be different
than a term grabbed directly from MySQL since the term grabbed from cache
would never be sanitized. I updated two of the unit tests to specifically
test for this.
* I added suspended cached invalidation awareness to address #28743.
* A unit test was added to test #28743.
Thoughts/questions:
* I'm starting to think that we shouldn't add the `if ( $cache )`
conditional. If the value is cached, the filters and sanitization
functions are completely missed. I can see an argument that the terms will
have already been run through the filters and sanitization routines;
however, this would cause problems if a user, using a persistent cache,
installs a plugin that should further manipulate these terms. The user
would need to wait until the next cache invalidation for it to take
effect. These things cause devs to go batty.
* We should probably add suspended cached invalidation awareness to
`update_term_cache()`, right? I looked at how this is handled in
`update_post_cache()` and it is not aware of suspended cached
invalidation; however, that is because the function is ''not an
invalidation function''. It will add items to cache, but does not
overwrite it or delete cached items. It will never do this.
`update_term_cache()` operates differently. It nukes the cached items and
forces an update. As such, it should respect suspended cached
invalidation, right?
--
Ticket URL: <https://core.trac.wordpress.org/ticket/21760#comment:48>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list