[wp-trac] [WordPress Trac] #32044: is_object_in_term() leaks DB queries
WordPress Trac
noreply at wordpress.org
Sat Oct 3 21:14:01 UTC 2015
#32044: is_object_in_term() leaks DB queries
------------------------------------------+---------------------------
Reporter: joehoyle | Owner: boonebgorges
Type: defect (bug) | Status: assigned
Priority: normal | Milestone: 4.4
Component: Taxonomy | Version: 4.1.1
Severity: normal | Resolution:
Keywords: needs-patch needs-unit-tests | Focuses:
------------------------------------------+---------------------------
Changes (by boonebgorges):
* milestone: Future Release => 4.4
Comment:
Circling back around here. I think the real historical reason why
`is_object_in_term()` doesn't update the object-term cache is because
object-term caches are usually update en masse, during
`update_object_term_cache()`. The latter function updates an object's term
relationships across all taxonomies.
I racked my brain trying to think of a way to cause a bug by setting the
object-term cache in `is_object_in_term()`, and I couldn't think of
anything. For example, there could be a problem if a user and a post had
the same ID, and a cache that had been primed for the post contained
different terms than belonged to the user. But this would require that a
single taxonomy was being shared by users and posts, which causes all
sorts of other bugs. (`wp_get_object_terms()` cannot distinguish between
different object types, so the SQL query itself would return incorrect
results.)
This points toward better general cache support for all taxonomy
relationships - maybe at the level of `wp_get_object_terms()` - but for
now, let's put it here and see if the world explodes.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/32044#comment:14>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list