Download & Extend

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

Project:Taxonomy HTML
Version:master
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed (fixed)

Issue Summary

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

Comments

#1

Project:Drupal core» 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

Version:<none>» master
Status:active» fixed

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

#3

Status:fixed» closed (fixed)
nobody click here