Make WordPress Core

Opened 10 years ago

Closed 7 years ago

Last modified 6 years ago

#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:

  1. If echoing the output, switch to the_tags().
  2. 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)

twentyfifteen.diff (685 bytes ) - added by sixhours 10 years ago.
Check for is_wp_error() before outputting get_the_tag_list() in Twenty Fifteen
twentyseventeen.diff (841 bytes ) - added by sixhours 10 years ago.
Check for is_wp_error() before outputting get_the_tag_list() in Twenty Seventeen
twentyten.diff (865 bytes ) - added by sixhours 10 years ago.
Check for is_wp_error() before outputting get_the_tag_list() in Twenty Ten
39860.1.patch (3.0 KB ) - added by davidakennedy 9 years ago.
Check for is_wp_error() before outputting get_the_tag_list().

Download all attachments as: .zip

Change History (12)

@sixhours
10 years ago

Check for is_wp_error() before outputting get_the_tag_list() in Twenty Fifteen

@sixhours
10 years ago

Check for is_wp_error() before outputting get_the_tag_list() in Twenty Seventeen

@sixhours
10 years ago

Check for is_wp_error() before outputting get_the_tag_list() in Twenty Ten

#1 @sixhours
10 years ago

Twenty Sixteen is also affected; I opened a PR: https://github.com/WordPress/twentysixteen/pull/496

#2 @swissspidy
10 years ago

  • Keywords has-patch needs-testing added
  • Version trunk

This ticket was mentioned in Slack in #core-themes by obenland. View the logs.


10 years ago

@davidakennedy
9 years ago

Check for is_wp_error() before outputting get_the_tag_list().

#4 @davidakennedy
9 years ago

I combined the patches from @sixhours and moved the PR from Twenty Sixteen over.

See: https://github.com/WordPress/twentysixteen/pull/496

#5 @davidakennedy
9 years ago

  • Milestone Awaiting ReviewFuture Release

#6 @ianbelanger
7 years ago

  • Resolutionfixed
  • Status newclosed

This appears to have already been fixed. Closing

#7 @SergeyBiryukov
6 years ago

  • Owner set to SergeyBiryukov

In 47886:

Bundled Themes: Consistently check for WP_Error before outputting get_the_tag_list().

Some themes already had these checks in place as a result of [41756], but not others.

Props sixhours, davidakennedy, SergeyBiryukov.
Fixes #39860.

#8 @SergeyBiryukov
6 years ago

  • Milestone Future Release5.5
Note: See TracTickets for help on using tickets.