anikesh / web-optimizator

Automatically exported from code.google.com/p/web-optimizator
0 stars 0 forks source link

PHP 5.4.1: Warning: Invalid argument supplied for foreach() in webo-site-speedup/controller/compressor.php on line 3314 #592

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
r3900 SVN Release has this 'E Notice'

PHP 5.4.1: Warning:  Invalid argument supplied for foreach() in 
webo-site-speedup/controller/compressor.php on line 3314

Solution:

Wrap the procedure as per: (add 'is_array()' ... )

+if (is_array($unobtrusive_items)) {
        foreach ($unobtrusive_items as $group => $items) {
            if (!empty($options[$group])) {
                foreach ($items as $key => $item) {
                    if (strpos($this->content, $item['marker'])) {
                        $before = $this->replace_unobtrusive_generic("@" . $item['regexp'] . "@is",
                            $key, empty($item['height']) ? 0 : $item['height'],
                            empty($item['inline']) ? false : $item['inline'],
                            empty($item['onload_before']) ? false : $item['onload_before'],
                            empty($item['onload_after']) ? false : $item['onload_after']);
/* switch between window.onload and onDOMready handlers */
                        if (!empty($item['onload_before']) && !empty($item['onload_after'])) {
                            $before_body_onload .= $before;
                        } else {
                            $before_body .= $before;
                        }
                    }
                }
            }
        }
+}

Thanks,
Peter

Original issue reported on code.google.com by peterbowey on 28 May 2012 at 2:39

GoogleCodeExporter commented 9 years ago
$unobtrusive_items are defined in config.unobtrusive.php which is included 
earlier. So ther eare issues with this file include, not with this array. 
Please check why you don't have $unobtrusive_items

Original comment by sunny.dr...@gmail.com on 28 May 2012 at 7:31

GoogleCodeExporter commented 9 years ago
This issue was closed by revision r3902.

Original comment by sunny.dr...@gmail.com on 28 May 2012 at 7:32