[wp-trac] [WordPress Trac] #42691: WP_Term_Query get_terms generates invalid sql queries
WordPress Trac
noreply at wordpress.org
Mon Dec 11 07:34:29 UTC 2017
#42691: WP_Term_Query get_terms generates invalid sql queries
--------------------------+------------------
Reporter: GM_Alex | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: 5.0
Component: Taxonomy | Version: 4.9
Severity: normal | Resolution:
Keywords: has-patch | Focuses:
--------------------------+------------------
Comment (by GM_Alex):
@boonebgorges Your patch works, but since `$term_ids` can be `false` we
should add an extra check, like
{{{#!php
protected function populate_terms( $term_ids ) {
if ( is_array($term_ids) === false ) {
return $term_ids;
}
$terms = array();
foreach ( $term_ids as $key => $term_id ) {
$term = get_term( $term_id );
if ( $term instanceof WP_Term ) {
$terms[ $key ] = $term;
}
}
return $terms;
}
}}}
Otherwise we get a warning.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/42691#comment:7>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list