[wp-trac] [WordPress Trac] #37568: `get_terms()` falsely assumes that legacy arguments are used

WordPress Trac noreply at wordpress.org
Thu Aug 4 14:11:25 UTC 2016


#37568: `get_terms()` falsely assumes that legacy arguments are used
--------------------------------------+------------------
 Reporter:  flixos90                  |       Owner:
     Type:  defect (bug)              |      Status:  new
 Priority:  normal                    |   Milestone:  4.7
Component:  Taxonomy                  |     Version:
 Severity:  normal                    |  Resolution:
 Keywords:  has-patch has-unit-tests  |     Focuses:
--------------------------------------+------------------
Changes (by boonebgorges):

 * milestone:  Awaiting Review => 4.7


Comment:

 @flixos90 - Thanks for the debugging and the patches.

 Adding the meta-related query params to the `$query_var_defaults` array
 seems like the right approach to me.

 > They could alternatively be placed directly in WP_Term_Query, but I
 think this approach makes more sense since several classes use
 WP_Meta_Query and could use its new method.

 This feels off to me. First, the naming is weird: what's really being
 provided here is the "default top-level query params that are supported by
 `parse_query_vars()`". (IMO, `meta_query` is a different kind of thing
 from `meta_key`, `meta_type`, etc.) This is hard to capture in a method
 name, which suggests to me that it's not a discrete enough concept to
 abstract in the way you've suggested. I'd like to explore a better way to
 centralize the definition and processing of `WP_*_Query` parameters, but
 this should be tackled as a larger project. Since `get_terms()` is the
 only place where the defaults are being used in this way, let's hold off
 on the additional abstraction. See [attachment:37568.3.diff].

 As @ocean90 notes, this dates to [36614], which means it's a regression in
 4.5, not 4.6. For this reason, I don't think it's necessary to put it into
 the 4.6 RC, but I'll let @ocean90 make the call there. @wonderboymusic In
 the meantime, you should be able to work around by passing any additional
 parameter to `get_terms()` - something redundant like:

 {{{
 $terms = get_terms( [
     'meta_key' => 'foo',
     'meta_value' => 1,
     'orderby' => 'name',
 ] );
 }}}

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


More information about the wp-trac mailing list