#54222 closed defect (bug) (fixed)
Document that the `get_terms` filter can have null for `$taxonomies`
Reported by: | dd32 | Owned by: | davidbaumwald |
---|---|---|---|
Milestone: | 5.9 | Priority: | normal |
Severity: | minor | Version: | |
Component: | Taxonomy | Keywords: | has-patch |
Focuses: | docs | Cc: |
Description
The get_terms
filter currently documents that the filter passes an array as both the first and second parameters, which is normally true, except that the second can be null when not specified.
The simplest way to trigger this scenario is to query for get_terms( [ 'term_taxonomy_id' => ?? ] );
which has no taxonomies to pass.
This can cause PHP Warnings and PHP Fatal errors in code that doesn't expect it.
See some real world examples:
Change History (8)
This ticket was mentioned in PR #1732 on WordPress/wordpress-develop by dd32.
3 years ago
#1
- Keywords has-patch added
#2
follow-up:
↓ 3
@
3 years ago
- Milestone changed from Awaiting Review to 5.9
Moving this for 5.9 consideration.
I'm wondering whether this should also be documented in other functions (like wp_terms_checklist and many others) or not.
Otherwise the PR looks good to me.
#3
in reply to:
↑ 2
@
3 years ago
Replying to audrasjb:
I'm wondering whether this should also be documented in other functions (like wp_terms_checklist and many others) or not.
I'm not sure where that comes into play having taken a quick look at those, this is just that one of the additional context parameters on the get_terms
filter is documented wrong, doesn't affect the return value (which is already Documented as being literally almost anything WP_Term[]|int[]|string[]|string|WP_Error
:) ).
dream-encode commented on PR #1732:
3 years ago
#8
Committed to core in changeset https://core.trac.wordpress.org/changeset/52131.
Trac ticket: https://core.trac.wordpress.org/ticket/54222