Make WordPress Core

Opened 12 years ago

Closed 12 years ago

#21155 closed defect (bug) (fixed)

Prevent warnings in get_the_category from unregistered "category" taxonomy

Reported by: batmoo's profile batmoo Owned by: nacin's profile nacin
Milestone: 3.5 Priority: normal
Severity: normal Version: 3.4
Component: General Keywords: has-patch
Focuses: Cc:

Description

get_the_terms can return a WP_Error object if the category taxonomy is not defined (something that sites can do if they want custom taxonomies). This results in some warnings from get_the_category because it assumes that the category taxonomy will always be there and it will always get a valid value back.

Warning: array_values() expects parameter 1 to be array, object given in /home/wpcom/public_html/wp-includes/category-template.php on line 79

Warning: array_keys() expects parameter 1 to be array, null given in /home/wpcom/public_html/wp-includes/category-template.php on line 81

Warning: Invalid argument supplied for foreach() in /home/wpcom/public_html/wp-includes/category-template.php on line 81

Attachments (1)

21155.diff (483 bytes) - added by batmoo 12 years ago.

Download all attachments as: .zip

Change History (5)

@batmoo
12 years ago

#1 @batmoo
12 years ago

  • Keywords has-patch added

Attached patches adds an is_wp_error check to prevent these warnings.

#3 @wonderboymusic
12 years ago

  • Milestone changed from Awaiting Review to 3.5

#4 @nacin
12 years ago

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

In 22412:

Check for WP_Error in get_the_category(). props batmoo. fixes #21155.

Note: See TracTickets for help on using tickets.