Try to read a empty array?

Found a bug? Tell us!!
Post Reply
iacques

Try to read a empty array?

Post 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
}
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Try to read a empty array?

Post 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
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Post Reply