overrides `customvarsWithOriginalNames` only if the given object is of type `host`

A call to `__get()` reset the array if the given `$name` is a customvar
If `service` has a `host` customvar filter, the `fetchHostVariables()`
method was executed and overwrote the `customvarsWithOriginalNames` array.

fixes #4757
This commit is contained in:
Sukhwinder Dhillon 2022-05-09 16:08:54 +02:00 committed by Johannes Meyer
parent c0d247613d
commit d8ddc6600a
1 changed files with 5 additions and 1 deletions

View File

@ -539,7 +539,11 @@ abstract class MonitoredObject implements Filterable
->whereEx(new FilterEqual('host_name', '=', $this->host_name));
$this->hostVariables = [];
$this->customvarsWithOriginalNames = [];
if ($this->type === static::TYPE_HOST) {
$this->customvarsWithOriginalNames = [];
}
foreach ($query as $row) {
if ($row->is_json) {
$this->hostVariables[strtolower($row->varname)] = json_decode($row->varvalue);