mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Small fix to not throw error if details is already empty (#9086)
This commit is contained in:
committed by
Tony Murray
parent
f2253d70fd
commit
b411f6c5d8
@@ -214,7 +214,10 @@ function RunRules($device_id)
|
||||
// NOCHG here doesn't mean no change full stop. It means no change to the alert state
|
||||
// So we update the details column with any fresh changes to the alert output we might have.
|
||||
$alert_log = dbFetchRow('SELECT alert_log.id, alert_log.details FROM alert_log,alert_rules WHERE alert_log.rule_id = alert_rules.id && alert_log.device_id = ? && alert_log.rule_id = ? && alert_rules.disabled = 0 ORDER BY alert_log.id DESC LIMIT 1', array($device_id, $rule['id']));
|
||||
$details = json_decode(gzuncompress($alert_log['details']), true);
|
||||
$details = [];
|
||||
if (!empty($alert_log['details'])) {
|
||||
$details = json_decode(gzuncompress($alert_log['details']), true);
|
||||
}
|
||||
$details['contacts'] = GetContacts($qry);
|
||||
$details['rule'] = $qry;
|
||||
$details = gzcompress(json_encode($details), 9);
|
||||
@@ -478,7 +481,10 @@ function DescribeAlert($alert)
|
||||
return false;
|
||||
}
|
||||
|
||||
$extra = json_decode(gzuncompress($id['details']), true);
|
||||
$extra = [];
|
||||
if (!empty($id['details'])) {
|
||||
$extra = json_decode(gzuncompress($id['details']), true);
|
||||
}
|
||||
|
||||
// Reset count to 0 so alerts will continue
|
||||
$extra['count'] = 0;
|
||||
@@ -689,7 +695,9 @@ function loadAlerts($where)
|
||||
$alert['alert_id'] = $alert_status['id'];
|
||||
$alert['state'] = $alert_status['state'];
|
||||
$alert['note'] = $alert_status['note'];
|
||||
$alert['details'] = json_decode(gzuncompress($alert['details']), true);
|
||||
if (!empty($alert['details'])) {
|
||||
$alert['details'] = json_decode(gzuncompress($alert['details']), true);
|
||||
}
|
||||
$alerts[] = $alert;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user