From 3cd3abab1a33459d3613fa342cbd8fd9135b1202 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Mon, 3 Apr 2017 13:51:34 +0200 Subject: [statistics_reporting] Convert NULL to 0 so stupidtable doesn't mess up --- modules-available/statistics_reporting/inc/getdata.inc.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'modules-available') diff --git a/modules-available/statistics_reporting/inc/getdata.inc.php b/modules-available/statistics_reporting/inc/getdata.inc.php index f65ee868..a167c2e5 100644 --- a/modules-available/statistics_reporting/inc/getdata.inc.php +++ b/modules-available/statistics_reporting/inc/getdata.inc.php @@ -40,6 +40,7 @@ class GetData $res = Queries::getLocationStatistics(self::$from, self::$to, self::$lowerTimeBound, self::$upperTimeBound); $data = array(); while ($row = $res->fetch(PDO::FETCH_ASSOC)) { + self::nullToZero($row); $median = self::calcMedian(self::calcMedian($row['medianSessionLength'])); $entry = array( 'location' => ($anonymize ? $row['locHash'] : $row['locName']), @@ -69,6 +70,7 @@ class GetData $res = Queries::getClientStatistics(self::$from, self::$to, self::$lowerTimeBound, self::$upperTimeBound); $data = array(); while ($row = $res->fetch(PDO::FETCH_ASSOC)) { + self::nullToZero($row); $median = self::calcMedian(self::calcMedian($row['medianSessionLength'])); $entry = array( 'hostname' => ($anonymize ? $row['clientHash'] : $row['clientName']), @@ -116,12 +118,20 @@ class GetData $data = array(); $vm = $anonymize ? 'vmHash' : 'name'; while ($row = $res->fetch(PDO::FETCH_ASSOC)) { + self::nullToZero($row); $data[] = array('vm' => $row[$vm], 'sessions' => $row['count']); } return $data; } - + private function nullToZero(&$row) + { + foreach ($row as &$field) { + if (is_null($field)) { + $field = 0; + } + } + } // Format $seconds into ".d .h .m .s" format (day, hour, minute, second) private static function formatSeconds($seconds) -- cgit v1.2.3-55-g7522