Skip to content

Commit

Permalink
Fix: Switching to the icingadb backend and searching host/service nod…
Browse files Browse the repository at this point in the history
…e in add/edit form throws an error (#443)

`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.

fixes
#430
  • Loading branch information
nilmerg authored Apr 19, 2024
2 parents 4428d78 + ad3c38e commit c4ca750
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ public function isValid($terms)
}

$isValid = true;
$testConfig = new BpConfig();
$testConfig = (new BpConfig())
->setBackend($this->parent->getBpConfig()->getBackend());

foreach ($terms as $term) {
/** @var Term $term */
Expand All @@ -68,7 +69,7 @@ public function isValid($terms)
}
}

if ($this->parent->getBpConfig()->getBackend() instanceof MonitoringBackend) {
if ($testConfig->getBackend() instanceof MonitoringBackend) {
MonitoringState::apply($testConfig);
} else {
IcingaDbState::apply($testConfig);
Expand Down
10 changes: 0 additions & 10 deletions phpstan-baseline-standard.neon
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c4ca750

Please sign in to comment.