Make WordPress Core

Opened 17 years ago

Closed 15 years ago

#5110 closed defect (bug) (invalid)

in_category function does no sanity checking

Reported by: tomsing1's profile tomsing1 Owned by: markjaquith's profile markjaquith
Milestone: Priority: normal
Severity: normal Version: 2.3
Component: Template Keywords: has-patch 2nd-opinion
Focuses: Cc:

Description

Using Wordpress 2.3 and themes "Fallseason 1.1" and "TerraFirma 3.4", I noticed the following warning displayed at the top of the page:

Warning: array_key_exists() [function.array-key-exists]: The first argument should be either a string or an integer in /wordpress/wp-includes/category-template.php on line 176

This problem was reported by others using different themes, too:
http://wordpress.org/support/topic/135658
http://wordpress.org/support/topic/132280

and it was suggested that this might be a bug in the "on_category" function itself, as it is not confined to any single theme.

Attachments (2)

in_category.diff (602 bytes) - added by stormerider 17 years ago.
Patch to add sanity checking to $category value
in_category2.diff (591 bytes) - added by markjaquith 17 years ago.

Download all attachments as: .zip

Change History (6)

@stormerider
17 years ago

Patch to add sanity checking to $category value

#1 @stormerider
17 years ago

  • Summary changed from on_category function in category-template.php outputs warning with different themes to in_category function does no sanity checking

This is in_category, not on_category.

Some error checking should be performed to see if $category is null, and if so, return false. Diff attached.

#2 @stormerider
17 years ago

  • Cc stormerider@… added

#3 @markjaquith
17 years ago

  • Keywords has-patch 2nd-opinion added
  • Milestone changed from 2.3.1 to 2.4
  • Owner changed from anonymous to markjaquith
  • Status changed from new to assigned

Updated patch casts $category to an absolute integer, and then checks if it is zero. Should catch more errors, such as in_category('category-name')

Patches go into trunk first, and then are considered for backporting to 2.3.1

#4 @Denis-de-Bernardy
15 years ago

  • Milestone 2.9 deleted
  • Resolution set to invalid
  • Status changed from assigned to closed

fixed in trunk

Note: See TracTickets for help on using tickets.