From f4d704fbd547bd492ea1b1972ea62f93f2f2cff1 Mon Sep 17 00:00:00 2001 From: Sukhwinder Dhillon Date: Wed, 27 Mar 2024 08:27:52 +0100 Subject: [PATCH] Fix: Switching to the icingadb backend and searching host/service node in add/edit form throws an error `HostServiceTermValidator`: `$testConfig` requires backend for `MonitoringState::apply()` call. If the `$testConfig` has no backend set and icingadb is in use, `MonitoringState::__construct($config) => $config->getBackend()` returns an icingadb backend that is not suitable for the `MonitoringState` class. --- .../Web/Form/Validator/HostServiceTermValidator.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/library/Businessprocess/Web/Form/Validator/HostServiceTermValidator.php b/library/Businessprocess/Web/Form/Validator/HostServiceTermValidator.php index 58249f7..a9db89e 100644 --- a/library/Businessprocess/Web/Form/Validator/HostServiceTermValidator.php +++ b/library/Businessprocess/Web/Form/Validator/HostServiceTermValidator.php @@ -45,7 +45,8 @@ class HostServiceTermValidator extends BaseValidator } $isValid = true; - $testConfig = new BpConfig(); + $testConfig = (new BpConfig()) + ->setBackend($this->parent->getBpConfig()->getBackend()); foreach ($terms as $term) { /** @var Term $term */ @@ -68,7 +69,7 @@ class HostServiceTermValidator extends BaseValidator } } - if ($this->parent->getBpConfig()->getBackend() instanceof MonitoringBackend) { + if ($testConfig->getBackend() instanceof MonitoringBackend) { MonitoringState::apply($testConfig); } else { IcingaDbState::apply($testConfig);