[wp-trac] [WordPress Trac] #39932: `get_terms()` with `name` and without `taxonomy` generates warning
WordPress Trac
noreply at wordpress.org
Wed Feb 22 02:03:19 UTC 2017
#39932: `get_terms()` with `name` and without `taxonomy` generates warning
--------------------------+-----------------------------
Reporter: dlh | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Taxonomy | Version:
Severity: normal | Keywords:
Focuses: |
--------------------------+-----------------------------
On a clean install, calling `get_terms( array( 'name' => array(
'uncategorized' ) ) )` generates a warning: `reset() expects parameter 1
to be array, null given in...class-wp-term-query.php on line 481`.
Earlier in `WP_Term_Query::get_terms()`, the `$taxonomies` variable is set
to `$args['taxonomy']`, but that argument is `null` by default.
The attached patch would cast `$args['taxonomy']` to an array before
assigning it to `$taxonomies`. Casting to an array fixes the warning and
seems consistent to me with the use of `$taxonomies` throughout the
method, which tends to assume it's an array.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/39932>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list