Ticket #3179 (closed defect: fixed)

Opened 2 years ago

Last modified 1 year ago

warning in category template function

Reported by: Denis-de-Bernardy Assigned to: anonymous
Priority: normal Milestone:
Component: Template Version: 2.0.4
Severity: major Keywords: has-patch
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

3179.diff (474 bytes) - added by Nazgul on 10/03/06 08:54:58.

Change History

10/01/06 21:18:53 changed by foolswisdom

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.

10/03/06 08:54:58 changed by Nazgul

  • attachment 3179.diff added.

10/03/06 08:57:10 changed by Nazgul

  • keywords set to has-patch.
  • 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.

10/03/06 22:04:36 changed by markjaquith

  • status changed from new to closed.
  • resolution set to fixed.

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

11/30/06 19:41:51 changed by

  • milestone deleted.

Milestone 2.0.5 deleted