IcingaArguments: allow to restore set_if_format

fixes #2291
This commit is contained in:
Thomas Gelf 2022-02-09 21:59:53 +01:00
parent 7ae1ed7798
commit aeef51ffa6

View File

@ -190,10 +190,14 @@ class IcingaArguments implements Iterator, Countable, IcingaConfigRenderer
} }
} }
if (array_key_exists('set_if', $attrs) && is_object($attrs['set_if'])) { if (array_key_exists('set_if', $attrs)) {
if ($attrs['set_if']->type === 'Function') { if (is_object($attrs['set_if']) && $attrs['set_if']->type === 'Function') {
$attrs['set_if'] = '/* Unable to fetch function body through API */'; $attrs['set_if'] = '/* Unable to fetch function body through API */';
$attrs['set_if_format'] = 'expression'; $attrs['set_if_format'] = 'expression';
} elseif (property_exists($value, 'set_if_format')) {
if (in_array($value->set_if_format, ['string', 'expression', 'json'])) {
$attrs['set_if_format'] = $value->set_if_format;
}
} }
} }