Opened 9 years ago
Closed 9 years ago
#39932 closed defect (bug) (fixed)
`get_terms()` with `name` and without `taxonomy` generates warning
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | 4.8 | Priority: | normal |
| Severity: | normal | Version: | |
| Component: | Taxonomy | Keywords: | |
| Focuses: | Cc: |
Description
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.
Attachments (1)
Change History (3)
Note: See
TracTickets for help on using
tickets.
Yes, I think this is right. Previously, it wasn't possible to query for terms without passing a taxonomy, so this problem never really arose in the past.