Ticket #3179 (closed defect (bug): fixed)

Opened 5 years ago

Last modified 2 years ago

warning in category template function

Reported by: Denis-de-Bernardy Owned by: anonymous
Priority: normal Milestone: 2.0.6
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 Download (474 bytes) - added by Nazgul 5 years ago.

Change History

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.

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

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

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

  • Milestone 2.0.5 deleted

Milestone 2.0.5 deleted

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