#16464 closed defect (bug) (fixed)
get_term_by() returns WP_Error as well
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | 3.1.1 |
| Component: | Warnings/Notices | Version: | 3.0 |
| Severity: | normal | Keywords: | |
| Cc: |
Description
It's not documented, but get_term_by() can return WP_Error as well in case it fails.
Code that checks for the return value only against being not empty is doing short as WP_Error never is empty.
The result are most often undefined property warnings.
Attachments (2)
Change History (13)
The second patch "corrects" the return value for the function get_term_by() based on the information in the function's docblock comment (return false on error).
- Keywords 3.2-early added
- Milestone changed from Awaiting Review to Future Release
- Version changed from 3.1 to 3.0
If that is indeed the only way for get_term_by() to return WP_Error (and that's what it looks like), then the fix looks good. They already needed to look for false anyway, so I'm fine with preventing the possibility of WP_Error being returned through get_term_by().
- Resolution set to fixed
- Status changed from new to closed
comment:10
automattor — 2 years ago
comment:11
hakre — 2 years ago
- Keywords has-patch 3.2-early removed

The related feature is: Advanced multi-taxonomy WP_Query()s (#12891)