From f4d704fbd547bd492ea1b1972ea62f93f2f2cff1 Mon Sep 17 00:00:00 2001 From: Sukhwinder Dhillon Date: Wed, 27 Mar 2024 08:27:52 +0100 Subject: [PATCH 1/2] 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); From ad3c38eba4ff4dc5cd6b97d748a9d05c97d33178 Mon Sep 17 00:00:00 2001 From: Sukhwinder Dhillon Date: Wed, 27 Mar 2024 09:00:35 +0100 Subject: [PATCH 2/2] Update phpstan baseline --- phpstan-baseline-standard.neon | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/phpstan-baseline-standard.neon b/phpstan-baseline-standard.neon index fa74e35..ebd45d2 100644 --- a/phpstan-baseline-standard.neon +++ b/phpstan-baseline-standard.neon @@ -4345,16 +4345,6 @@ parameters: count: 1 path: library/Businessprocess/Web/Form/QuickForm.php - - - message: "#^Call to an undefined method Icinga\\\\Module\\\\Businessprocess\\\\BpNode\\|Icinga\\\\Module\\\\Businessprocess\\\\MonitoredNode\\:\\:addChild\\(\\)\\.$#" - count: 1 - path: library/Businessprocess/Web/Form/Validator/HostServiceTermValidator.php - - - - message: "#^Parameter \\#1 \\$label of method ipl\\\\Web\\\\FormElement\\\\TermInput\\\\Term\\:\\:setLabel\\(\\) expects string, string\\|null given\\.$#" - count: 1 - path: library/Businessprocess/Web/Form/Validator/HostServiceTermValidator.php - - message: "#^Method Icinga\\\\Module\\\\Businessprocess\\\\Web\\\\Navigation\\\\Renderer\\\\ProcessProblemsBadge\\:\\:getBpConfigName\\(\\) has no return type specified\\.$#" count: 1