From 09847016b8816b5fbf37aeb5af93cd553f76b8ac Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Thu, 18 Jan 2024 14:40:35 +0100 Subject: [locations/statistics] More type safety, array key checks --- modules-available/statistics/pages/list.inc.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'modules-available/statistics/pages/list.inc.php') diff --git a/modules-available/statistics/pages/list.inc.php b/modules-available/statistics/pages/list.inc.php index facffdd0..f08cd71c 100644 --- a/modules-available/statistics/pages/list.inc.php +++ b/modules-available/statistics/pages/list.inc.php @@ -76,6 +76,7 @@ class SubPage $rows = []; $colValCount = []; // Count unique values for several columns foreach ($allRows as &$row) { + settype($row['locationid'], 'int'); $row['link_details'] = in_array($row['locationid'], $detailsAllowedLocations); //$row['firstseen'] = Util::prettyTime($row['firstseen']); $row['lastseen_int'] = $row['lastseen']; @@ -157,8 +158,9 @@ class SubPage $roomsvg = null; $side = []; if (!empty($rows) && !empty($colValCount)) { - if (count($colValCount['locationid']) === 1 && ($lid = array_key_first($colValCount['locationid'])) !== null - && Module::isAvailable('roomplanner')) { + if (count($colValCount['locationid']) === 1 + && ($lid = array_key_first($colValCount['locationid'])) > 0 + && Module::isAvailable('roomplanner')) { $roomsvg = PvsGenerator::generateSvg($lid, false, 0, 1, true, $colValCount['locationid'][$lid]); } // Handle our selected attributes @@ -168,6 +170,8 @@ class SubPage // Suffixes are not localized, but hopefully generic enough for now switch ($key) { case 'locationid': + if (!isset($location[$val])) + continue 2; $val = $location[$val]['name']; break; case 'gbram': -- cgit v1.2.3-55-g7522