#56327 closed defect (bug) (fixed)
Correct returntype for `wp_get_object_terms()`
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 6.1 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Taxonomy | Keywords: | has-patch commit |
Focuses: | docs | Cc: |
Description
Currently the wp_get_object_terms()
function and the get_object_terms
/ wp_get_object_terms
filters specify that the return value is WP_Term[]
or WP_Term[] | WP_Error
, but that's not correct.
wp_get_object_terms()
ultimately wraps get_terms()
and per the $args
that are passed through, accepts a field
value which is best described by WP_Term_Query::__construct().
As a result, the data-type is better described by the return value of get_terms()
: WP_Term[]|int[]|string[]|string|WP_Error
. If one assumes the current documentation, you'll likely run into fatal errors when the calling code expected it to be int[]
or string[]
.
Change History (11)
This ticket was mentioned in PR #3056 on WordPress/wordpress-develop by audrasjb.
2 years ago
#2
- Keywords has-patch added; needs-patch removed
2 years ago
#3
Per ticket, this should also touch the filter value for the get_object_terms
and wp_get_object_terms
filters
#4
@
2 years ago
- Keywords changes-requested added
@audrasjb Could you refresh the PR to address the additional items noted by @dd32?
#6
@
2 years ago
- Keywords dev-feedback added; changes-requested removed
I updated the PR accordingly. Waiting for @dd32's feedback before commit.
#7
@
2 years ago
- Keywords changes-requested added
@audrasjb the PR #3056 is closed now. Can you please reopen it as PR looks good to me.
@dd32 can you please review?
#8
@
2 years ago
- Keywords changes-requested removed
Ah yes, thanks, I somehow closed it by mistake :)
Reopened for review.
#9
@
2 years ago
- Keywords commit added; dev-feedback removed
Thanks @audrasjb. PR 3056 looks good to me and approved.
#10
@
2 years ago
- Owner set to audrasjb
- Resolution set to fixed
- Status changed from new to closed
In 54441:
2 years ago
#11
Committed in https://core.trac.wordpress.org/changeset/54441
Trac ticket: https://core.trac.wordpress.org/ticket/56327