From b7be6ba7ed302e18a313af4cbb2827b1fb62193a Mon Sep 17 00:00:00 2001 From: Peter Wu Date: Sun, 20 Jul 2014 15:59:51 +0200 Subject: Fix type confusion index.php expects that collectd_hosts() always return an array for array_diff. Since an empty array evaluates to FALSE anyway, do not change the type and just return the empty array. In base.php, if no files are returned, the loop is never called and three variables are not initialized. Do it now. --- inc/collectd.inc.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'inc/collectd.inc.php') diff --git a/inc/collectd.inc.php b/inc/collectd.inc.php index fda685d..761f7c4 100644 --- a/inc/collectd.inc.php +++ b/inc/collectd.inc.php @@ -9,7 +9,7 @@ function collectd_hosts() { global $CONFIG; if (!is_dir($CONFIG['datadir'])) - return false; + return array(); $dir = array_diff(scandir($CONFIG['datadir']), array('.', '..')); foreach($dir as $k => $v) { @@ -17,7 +17,7 @@ function collectd_hosts() { unset($dir[$k]); } - return $dir ? $dir : false; + return $dir; } @@ -36,7 +36,7 @@ function get_host_rrd_files($dir) { $files[] = str_replace($dir.'/', '', $object->getPathname()); } - return $files ? $files : false; + return $files; } -- cgit v1.1