Making WordPress.org

Opened 8 years ago

Closed 8 years ago

#2591 closed defect (bug) (fixed)

User Badges plugin should check for WP_Error in ::get_author_badge_info()

Reported by: sergeybiryukov's profile SergeyBiryukov Owned by: coffee2code's profile coffee2code
Milestone: Priority: normal
Component: Support Forums Keywords: has-patch commit
Cc:

Description

wp_get_post_terms() can return an empty array if no terms were found, or a WP_Error object if the taxonomy does not exist.

User_Badges\Plugin::get_author_badge_info() has a check for the former, but not for the latter. Normally, this code only runs when the taxonomy exists, but it can still lead to a fatal error if WPORG_SUPPORT_FORUMS_BLOGID is not defined (e.g. to differentiate between English and Rosetta forums on a local install):

Fatal error: Uncaught Error: Cannot use object of type WP_Error as array in wp-content/plugins/wporg-bbp-user-badges/inc/class-plugin.php:142

Attachments (1)

2591.patch (544 bytes) - added by SergeyBiryukov 8 years ago.

Download all attachments as: .zip

Change History (2)

@SergeyBiryukov
8 years ago

#1 @coffee2code
8 years ago

  • Owner set to coffee2code
  • Resolution set to fixed
  • Status changed from new to closed

In 5156:

Support Forums, User Badges: Also check that wp_get_post_terms() did not return WP_Error for taxonomy not existing.

Props SergeyBiryukov.
Fixes #2591.

Note: See TracTickets for help on using tickets.