[wp-trac] [WordPress Trac] #42691: WP_Term_Query get_terms generates invalid sql queries

WordPress Trac noreply at wordpress.org
Mon Apr 30 22:27:04 UTC 2018


#42691: WP_Term_Query get_terms generates invalid sql queries
--------------------------+---------------------
 Reporter:  GM_Alex       |       Owner:  (none)
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  4.9.7
Component:  Taxonomy      |     Version:  4.9
 Severity:  normal        |  Resolution:
 Keywords:  has-patch     |     Focuses:
--------------------------+---------------------

Comment (by boonebgorges):

 Replying to [comment:11 swissspidy]:
 > What's the benefit of `WP_Term_Query::populate_terms()` over
 `array_filter( array_map( 'get_term', $terms ) )`?

 That won't work if `$terms` is not an array. But yes, `array_filter()`
 could be used to shorten:

 {{{
 if ( is_array( $terms ) {
   $terms = array_filter( array_map( 'get_term', $terms ) );
 } else {
   $terms = array();
 }
 }}}

 The separate method is to avoid duplicating the logic, but if there's
 concern about adding the method, it's not hugely problematic to repeat it.

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


More information about the wp-trac mailing list