[wp-trac] [WordPress Trac] #37198: Use `WP_Term_Query` for `wp_get_object_terms()`

WordPress Trac noreply at wordpress.org
Fri Sep 23 21:26:58 UTC 2016


#37198: Use `WP_Term_Query` for `wp_get_object_terms()`
-----------------------------------+------------------
 Reporter:  flixos90               |       Owner:
     Type:  enhancement            |      Status:  new
 Priority:  normal                 |   Milestone:  4.7
Component:  Taxonomy               |     Version:  4.6
 Severity:  normal                 |  Resolution:
 Keywords:  has-patch 2nd-opinion  |     Focuses:
-----------------------------------+------------------

Comment (by boonebgorges):

 > Are you planning to add documentation and default params back in? You
 could probably merge a lot of my first patch for that. Looking forward to
 see a comprehensive patch. :)

 Sorry about this, I got lazy :)

 [attachment:37198.3.diff] is a more complete patch. It adds back in the
 documentation etc. Also:

 - I'm enforcing the 'term_count' thing by changing the value of 'order' to
 something legal before passing it to `parse_orderby()`
 - I moved the deduplication logic so that it can be done in a single block
 (instead of conditionally using `array_unique()`)
 - Added some tests

 So, fun fact, this change adds caching to all `wp_get_object_terms()`
 calls. Yet we still have a separate `{$taxonomy}_relationships` cache. We
 can't easily tear the latter bit out, because it's scattered through the
 codebase. Plus, it's a more durable cache than the `WP_Term_Query` cache,
 because `WP_Term_Query` is based on `last_changed`, which will be bumped
 pretty frequently. Still, having two layers of cache makes me uneasy. I
 wrote a test that demonstrates that things are working OK. Do you have
 thoughts about it, @flixos90 ?

--
Ticket URL: <https://core.trac.wordpress.org/ticket/37198#comment:7>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list