From c4c8a728f2fa129bf8aa4939ddb574d2e79db161 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 10 Oct 2018 19:04:00 -0400 Subject: [PATCH] Handle no controls found more gracefully --- web/includes/Monitor.php | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/web/includes/Monitor.php b/web/includes/Monitor.php index e425e7f85..717b9e1ee 100644 --- a/web/includes/Monitor.php +++ b/web/includes/Monitor.php @@ -152,19 +152,23 @@ private $control_fields = array( } if ( $this->{'Controllable'} ) { $s = dbFetchOne('SELECT * FROM Controls WHERE Id=?', NULL, array($this->{'ControlId'}) ); - foreach ($s as $k => $v) { - if ( $k == 'Id' ) { - continue; -# The reason for these is that the name overlaps Monitor fields. - } else if ( $k == 'Protocol' ) { - $this->{'ControlProtocol'} = $v; - } else if ( $k == 'Name' ) { - $this->{'ControlName'} = $v; - } else if ( $k == 'Type' ) { - $this->{'ControlType'} = $v; - } else { - $this->{$k} = $v; + if ( $s ) { + foreach ($s as $k => $v) { + if ( $k == 'Id' ) { + continue; + # The reason for these is that the name overlaps Monitor fields. + } else if ( $k == 'Protocol' ) { + $this->{'ControlProtocol'} = $v; + } else if ( $k == 'Name' ) { + $this->{'ControlName'} = $v; + } else if ( $k == 'Type' ) { + $this->{'ControlType'} = $v; + } else { + $this->{$k} = $v; + } } + } else { + Warning('No Controls found for monitor '.$this->{'Id'} . ' ' . $this->{'Name'}.' althrough it is marked as controllable'); } } global $monitor_cache;