Ticket #5110 (assigned defect (bug))

Opened 1 year ago

Last modified 1 year ago

in_category function does no sanity checking

Reported by: tomsing1 Assigned to: markjaquith (accepted)
Priority: normal Milestone: 2.9
Component: Template Version: 2.3
Severity: normal Keywords: has-patch 2nd-opinion
Cc: stormerider@gmail.com

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

in_category.diff (0.6 kB) - added by stormerider on 10/09/07 13:55:07.
Patch to add sanity checking to $category value
in_category2.diff (0.6 kB) - added by markjaquith on 10/09/07 17:50:01.

Change History

10/09/07 13:55:07 changed by stormerider

  • attachment in_category.diff added.

Patch to add sanity checking to $category value

10/09/07 13:55:52 changed by stormerider

  • 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.

10/09/07 13:56:34 changed by stormerider

  • cc set to stormerider@gmail.com.

10/09/07 17:50:01 changed by markjaquith

  • attachment in_category2.diff added.

10/09/07 17:51:19 changed by markjaquith

  • keywords set to has-patch 2nd-opinion.
  • owner changed from anonymous to markjaquith.
  • status changed from new to assigned.
  • milestone changed from 2.3.1 to 2.4.

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