From 58d298aa89cd11e5c9404c03d9ef421a100ac648 Mon Sep 17 00:00:00 2001 From: Thibault Debatty <thibault.debatty@gmail.com> Date: Fri, 3 Aug 2018 09:51:26 +0200 Subject: [PATCH] Handle no update information --- web/app/Sensor/Updates.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/web/app/Sensor/Updates.php b/web/app/Sensor/Updates.php index 578fb44..86928e6 100644 --- a/web/app/Sensor/Updates.php +++ b/web/app/Sensor/Updates.php @@ -33,6 +33,10 @@ class Updates extends \App\AbstractSensor { } $status = $this->parse($record->updates); + if ($status == null) { + return self::STATUS_UNKNOWN; + } + if ($status["security"] != 0) { return self::STATUS_WARNING; } @@ -42,7 +46,10 @@ class Updates extends \App\AbstractSensor { public function parse($string) { $matches = []; - preg_match(self::REGEXP, $string, $matches); + if (!preg_match(self::REGEXP, $string, $matches)) { + return null; + } + $result["updates"] = $matches[1]; $result["security"] = $matches[2]; return $result; -- GitLab