Arrays not checked before using in foreach loop in taxonomy_html.module

malfunct - December 6, 2003 - 07:26
Project:Taxonomy HTML
Version:HEAD
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed
Description

I found this issue when I went to the settings page for the taxonomy_html module and got an error message that there was an invalid parameter to a foreach() statement. I looked at the line with the error and found that because I had no ommited vocabularies the value given to that loop was either not an array or empty which caused the error. When I looked through the code there are a number of times where a value is grabbed with variable_get and then used in the next line inside a foreach statement. It would be best if the value was checked to make sure it was an array and that it had elements to loop though (I used

<?php
if(is_array($arrayvar) AND (count($arrayvar)>0)) {
?>
... to solve the problem in that one spot).

#1

moshe weitzman - December 28, 2003 - 03:39
Project:Drupal» Taxonomy HTML
Component:other» Code

the preferred way to fix this sort of bug is to fix the caller so it doesn't pass a non-array. in this case, the variable_get() which grabs the omitted vocabs should return array() if no vocabs are omitted.

recategorizing for taxonomy_html project

#2

Gábor Hojtsy - December 18, 2006 - 12:41
Version:<none>» HEAD
Status:active» fixed

Now the variable_get() has an array() default argument, so this problem is solved.

#3

Anonymous - January 1, 2007 - 12:45
Status:fixed» closed
 
 

Drupal is a registered trademark of Dries Buytaert.