Refactor fallback logic for submetrics

- Updated condition to check maxage existence before comparison.
This commit is contained in:
Jeroen De Meerleer 2024-06-04 16:59:23 +02:00
parent 9707a3cfb9
commit 8d0959b21c
Signed by: JeroenED
GPG Key ID: 28CCCB8F62BFADD6

View File

@ -78,7 +78,7 @@ if(php_sapi_name() == 'cli' || $_SERVER["REQUEST_URI"] == '/metrics') {
if(!empty($oldconfig) && empty($submetric['value']) && (isset($submetric['fallback']) && !empty($submetric['fallback']))) {
if(time() < ($oldconfig[$key]['submetrics'][$subkey]['time'] + $submetric['fallback']['maxage'])) {
if(!isset($submetric['fallback']['maxage']) || time() < ($oldconfig[$key]['submetrics'][$subkey]['time'] + $submetric['fallback']['maxage'])) {
if($submetric['fallback']['type'] == 'previous') {
$submetric['value'] = $oldconfig[$key]['submetrics'][$subkey]['value'];
} elseif ($submetric['fallback']['type'] == 'static') {