Skip to content

Commit a7aaaac

Browse files
committed
Fix alert detail count missing (try2) (librenms#16309)
1 parent c7c8f5d commit a7aaaac

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

LibreNMS/Alert/RunAlerts.php

+6-1
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,11 @@ public function runAlerts()
391391
$rextra['recovery'] = true;
392392
}
393393

394+
if (! isset($alert['details']['count'])) {
395+
// make sure count is set for below code, in legacy code null would get type juggled to 0
396+
$alert['details']['count'] = 0;
397+
}
398+
394399
$chk = dbFetchRow('SELECT alerts.alerted,devices.ignore,devices.disabled FROM alerts,devices WHERE alerts.device_id = ? && devices.device_id = alerts.device_id && alerts.rule_id = ?', [$alert['device_id'], $alert['rule_id']]);
395400

396401
if ($chk['alerted'] == $alert['state']) {
@@ -432,7 +437,7 @@ public function runAlerts()
432437
}
433438
}
434439

435-
if (in_array($alert['state'], [AlertState::ACTIVE, AlertState::WORSE, AlertState::BETTER]) && ! empty($rextra['count']) && isset($alert['details']['count']) && ($rextra['count'] == -1 || $alert['details']['count']++ < $rextra['count'])) {
440+
if (in_array($alert['state'], [AlertState::ACTIVE, AlertState::WORSE, AlertState::BETTER]) && ! empty($rextra['count']) && ($rextra['count'] == -1 || $alert['details']['count']++ < $rextra['count'])) {
436441
if ($alert['details']['count'] < $rextra['count']) {
437442
$noacc = true;
438443
}

0 commit comments

Comments
 (0)