Page 1 of 1

Try to read a empty array?

Posted: Tue Apr 05, 2005 8:41 am
by iacques
File: functions.inc.php;
Line: 124 (DMX04);
Error: Try to read a empty array;
Solution: Test if variable is array before foreach.


if(is_array($ary)){ // My sugestion start here
// original code start here
foreach ($ary as $data) {
if ($parentid === VIEWMODE_LINEAR || !isset($data[$parent_name]) || $data[$parent_name] == $parentid) {
$data['depth'] = $depth;
$_resArray[] = $data;
if ($data[$child_name] && $parentid !== VIEWMODE_LINEAR ) {
serendipity_walkRecursive($ary, $child_name, $parent_name, $data[$child_name], ($depth+1));
}
}
}
// original code ends here
}

Re: Try to read a empty array?

Posted: Tue Apr 05, 2005 10:47 am
by garvinhicking
We ensure that an array is passed to the function earlier before the function call is made, I think. So there's no need to inject another if-clause, as it costs performance.

Thanks for looking into this though, thanks!

Regards,
Garvin