[wp-trac] [WordPress Trac] #35381: Introduce `WP_Term_Query`

WordPress Trac noreply at wordpress.org
Thu May 26 03:57:39 UTC 2016

#35381: Introduce `WP_Term_Query`
 Reporter:  boonebgorges                          |       Owner:
     Type:  defect (bug)                          |      Status:  new
 Priority:  normal                                |   Milestone:  4.6
Component:  Taxonomy                              |     Version:
 Severity:  normal                                |  Resolution:
 Keywords:  has-patch needs-testing dev-feedback  |     Focuses:

Comment (by boonebgorges):

 > It's only the check for hierarchical taxonomies that you moved right? I
 can't quite remember why I left it in there, but looking at it now, I
 agree moving it into the class.

 Yeah. The check for invalid taxonomies stays in `get_terms()`, because
 it's the only place where `get_terms()` currently returns a `WP_Error`.
 This way, we can simplify the return value of `WP_Term_Query::get_terms()`
 - it'll always be an array.

 > Is there a good reason why the results are only cached for a day?

 [15583] #11431 Since that conversation, I feel like there's been a move in
 core to take less of an opinionated position on the internals of cache
 backends. The attitude is that it's really up to the cache, not WP, to set
 decent eviction policies. I'd be in favor of readdressing this and coming
 up with some sort of general policy about it, but this ticket is not the
 place, and we need more justification than the whim of the people in this
 conversation :)

 > I also think that the value stored in cache should be just an array of
 ids. I don't think we should be storing the whole object in there, as it
 not required and will just use up memory.

 See #34239, [comment:10 comment 10], [comment:11 comment 11]

 > Can we start thinking about get_the_terms() yet?

 See #36814. Since `get_the_terms()` uses `wp_get_object_terms()`, I don't
 think it's directly related. I do think we should try to adapt
 `WP_Term_Query` for use in `wp_get_object_terms()`, but I think it will be
 much harder than what we've done here. We should set up a separate ticket
 for it so that it doesn't hold up the current improvement for 4.6. See
 #31105, #29942.

 > What should be the next steps here?

 Let's do it.

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

More information about the wp-trac mailing list