Bug #101
Warning displayed : Invalid argument supplied for foreach() in .../redirector.php one line 87
Status : Closed Start : 03/11/2008
Priority : Normal Due date :
Assigned to : - % Done :
0%
Category : -
Target version : -
Description
Hello,
I have Wordpress hosted by free.fr and the first
time I ran redirection 1.7.26 , I got the following warning :
Warning: Invalid argument supplied for foreach() in
on line 87
Obviously "free.fr" displays warning !
After some digging, it seems that if we have
if( is_array($file))
{
foreach ($files AS $file)
{
if (is_dir ($file))
@include_once (dirname ($file).'/'.basename ($file).'.php');
else
@include_once ($file);
}
}
instead of
foreach ($files AS $file)
{
if (is_dir ($file))
@include_once (dirname ($file).'/'.basename ($file).'.php');
else
@include_once ($file);
}
in the file models/redirection/redirector.php, the warning goes
away.
I'm not very familiar with php but the page [1] mentions that [1] http://fr.php.net/glob
The example on this page will generate a warning if the glob
function does not find any filenames that match the pattern.
The glob function result will only be an array if it finds some files and the
foreach statement requires its argument to be an array.
By checking for the possibility that the result of the glob function may not
be an array you can eliminate the warning.
Here's a better example: