#39860 closed defect (bug) (fixed)
Multiple Themes: Check for WP_Error before outputting `get_the_tag_list()`
| Reported by: | sixhours | Owned by: | SergeyBiryukov |
|---|---|---|---|
| Priority: | normal | Milestone: | 5.5 |
| Component: | Bundled Theme | Version: | |
| Severity: | normal | Keywords: | has-patch needs-testing |
| Cc: | Focuses: |
Description
We've seen this error pop up on WordPress.com for multiple _s-based and default themes:
Catchable fatal error - Object of class WP_Error could not be converted to string
This happens because get_the_tag_list() can return an object of WP_Error and the theme doesn't account for it. Core handles it gracefully if the theme uses the_tags() instead.
Affected themes:
- Twenty Seventeen
- Twenty Fifteen
- Twenty Thirteen
- Twenty Twelve
- Twenty Eleven
- Twenty Ten
I propose we patch these to account for WP_Error. Two possible solutions:
- If echoing the output, switch to
the_tags(). - If returning the tags list, add a catch for
is_wp_error()in the function to avoid the fatal error.
I'll add some patches to get this started.
Attachments (4)
Change History (12)
#1
@
10 years ago
Twenty Sixteen is also affected; I opened a PR: https://github.com/WordPress/twentysixteen/pull/496
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Check for is_wp_error() before outputting get_the_tag_list() in Twenty Fifteen