Opened 6 years ago
Closed 6 years ago
#50344 closed defect (bug) (fixed)
Update @return docs for get_tags() to reflect that WP_Error is a possible return value
| Reported by: | coffee2code | Owned by: | SergeyBiryukov |
|---|---|---|---|
| Priority: | low | Milestone: | 5.5 |
| Component: | Taxonomy | Version: | |
| Severity: | minor | Keywords: | has-patch |
| Cc: | Focuses: | docs |
Description
get_tags(), by virtue of its call to get_terms(), has the potential to return a WP_Error object (if a specified taxonomy does not exist).
Unlike the similar get_categories(), get_tags() does not check for an error and return an empty array if there is one, so a WP_Error object can be returned by get_tags().
Patch attached.
Quick demonstration of return value:
$ wp eval "var_dump( get_tags( [ 'taxonomy' => 'xyz' ] ) );"
object(WP_Error)#1621 (2) {
["errors"]=>
array(1) {
["invalid_taxonomy"]=>
array(1) {
[0]=>
string(17) "Invalid taxonomy."
}
}
["error_data"]=>
array(0) {
}
}
Attachments (1)
Change History (3)
Note:
See TracTickets
for help on using tickets.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Patch mentioned in ticket.