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 |
Jump to:
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)) {
?>
#1
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
Now the variable_get() has an array() default argument, so this problem is solved.
#3