EditNodeForm: Fix handling of manually changed service node name

Previously, a manually changed service node name was always treated as
a host node, causing validation to fail with "Host not found" when the
input contained a service name, e.g. <serviceName on hostName>.

Replace unnecessary `getNode()` calls with explicit `createHost()` or
`createService()` call.
This commit is contained in:
Sukhwinder Dhillon 2026-03-23 15:46:42 +01:00 committed by Eric Lippmann
parent c552b1db7b
commit 5b0d7a40a3

View file

@ -126,7 +126,12 @@ class EditNodeForm extends CompatForm
$node = $this->bp->getNode($nodeName);
} elseif ($userInput && (! $nodeLabel || $userInput !== $nodeLabel)) {
// User didn't choose a suggestion or changed it manually
$node = $this->bp->getNode(BpConfig::joinNodeName($userInput, 'Hoststatus'));
if ($this->node instanceof ServiceNode) {
[$service, $host] = explode(' on ', $userInput, 2);
$node = $this->bp->createService($host, $service);
} else {
$node = $this->bp->createHost($userInput);
}
} else {
// If the search and user input are both empty, it can only be the initial value
$node = $this->node;