Fix alert detail count missing (try2) (#16309)

This commit is contained in:
Tony Murray 2024-08-21 21:41:22 -05:00
parent c7c8f5dfc1
commit a7aaaac103
No known key found for this signature in database
GPG Key ID: E57F02A35A950069

View File

@ -391,6 +391,11 @@ class RunAlerts
$rextra['recovery'] = true;
}
if (! isset($alert['details']['count'])) {
// make sure count is set for below code, in legacy code null would get type juggled to 0
$alert['details']['count'] = 0;
}
$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']]);
if ($chk['alerted'] == $alert['state']) {
@ -432,7 +437,7 @@ class RunAlerts
}
}
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'])) {
if (in_array($alert['state'], [AlertState::ACTIVE, AlertState::WORSE, AlertState::BETTER]) && ! empty($rextra['count']) && ($rextra['count'] == -1 || $alert['details']['count']++ < $rextra['count'])) {
if ($alert['details']['count'] < $rextra['count']) {
$noacc = true;
}