WordPress.org

Make WordPress Core

Opened 9 years ago

Closed 9 years ago

Last modified 6 years ago

#3179 closed defect (bug) (fixed)

warning in category template function

Reported by: Denis-de-Bernardy Owned by:
Milestone: 2.0.6 Priority: normal
Severity: major Version: 2.0.4
Component: Template Keywords: has-patch
Focuses: Cc:

Description

Warning: Invalid argument supplied for foreach() in /home/dolelm/public_html/testblog/wp-includes/template-functions-category.php on line 321

You can get this error when all categories are excluded using the available hook to drop categories.

to fix, cast $categories on line 304 as an array, i.e.:

		$query = "
			SELECT cat_ID, cat_name, category_nicename, category_description, category_parent, category_count
			FROM $wpdb->categories
			WHERE cat_ID > 0 $exclusions
			ORDER BY $sort_column $sort_order";

		$categories = (array) $wpdb->get_results($query);

D.

Attachments (1)

3179.diff (474 bytes) - added by Nazgul 9 years ago.

Download all attachments as: .zip

Change History (6)

comment:1 @foolswisdom9 years ago

Hi Denis-de-Bernardy,

Thank you!

If you have a fix please attach it as a patch -- even when it is trivial, it helps.

Also, if you can explicitly identify whether you have tested on trunk or not that is also very helpful.

@Nazgul9 years ago

comment:2 @Nazgul9 years ago

  • Keywords has-patch added
  • Milestone set to 2.0.5

Patch for 2.0.x based on the code provided by Denis-de-Bernardy.

template-functions-category.php no longer exists in trunk and a quick search didn't give me that code in another file, so I'm assuming this is a 2.0 only issue.

comment:3 @markjaquith9 years ago

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

(In [4280]) cast to array. props to Denis de Bernardy, Nazgul. fixes #3179

comment:4 @anonymous8 years ago

  • Milestone 2.0.5 deleted

Milestone 2.0.5 deleted

comment:5 @Denis-de-Bernardy6 years ago

  • Milestone changed from Unassigned to 2.0.6
Note: See TracTickets for help on using tickets.