mirror of
https://github.com/Icinga/icingaweb2-module-businessprocess.git
synced 2025-12-29 10:09:35 -05:00
BusinessProcess, BpNode: improve legacy storage
Before this fix depending on tree structure processes used multiple times as a sub-node could have been stored multiple times, resulting in warnings at render time.
This commit is contained in:
parent
f5facc02d1
commit
3009a28d3d
2 changed files with 12 additions and 4 deletions
|
|
@ -262,6 +262,10 @@ class BpNode extends Node
|
|||
public function toLegacyConfigString(& $rendered = array())
|
||||
{
|
||||
$cfg = '';
|
||||
if (array_key_exists($this->name, $rendered)) {
|
||||
return $cfg;
|
||||
}
|
||||
$rendered[$this->name] = true;
|
||||
$children = array();
|
||||
|
||||
foreach ($this->getChildren() as $name => $child) {
|
||||
|
|
@ -270,7 +274,6 @@ class BpNode extends Node
|
|||
if ($child instanceof BpNode) {
|
||||
$cfg .= $child->toLegacyConfigString($rendered) . "\n";
|
||||
}
|
||||
$rendered[$name] = true;
|
||||
}
|
||||
$eq = '=';
|
||||
$op = $this->operator;
|
||||
|
|
@ -278,11 +281,16 @@ class BpNode extends Node
|
|||
$eq = '= ' . $op . ' of:';
|
||||
$op = '+';
|
||||
}
|
||||
|
||||
$strChildren = implode(' ' . $op . ' ', $children);
|
||||
if ((count($children) < 2) && $op !== '&') {
|
||||
$strChildren = $op . ' ' . $strChildren;
|
||||
}
|
||||
$cfg .= sprintf(
|
||||
"%s %s %s\n",
|
||||
$this->name,
|
||||
$eq,
|
||||
implode(' ' . $op . ' ', $children)
|
||||
$strChildren
|
||||
);
|
||||
if ($this->hasAlias() || $this->getDisplay() > 0) {
|
||||
$prio = $this->getDisplay();
|
||||
|
|
|
|||
|
|
@ -629,12 +629,12 @@ class BusinessProcess
|
|||
|
||||
$rendered = array();
|
||||
foreach ($this->getChildren() as $child) {
|
||||
$rendered[(string) $child] = true;
|
||||
$conf .= $child->toLegacyConfigString($rendered);
|
||||
$rendered[(string) $child] = true;
|
||||
}
|
||||
foreach ($this->getUnboundNodes() as $node) {
|
||||
$rendered[(string) $node] = true;
|
||||
$conf .= $node->toLegacyConfigString($rendered);
|
||||
$rendered[(string) $node] = true;
|
||||
}
|
||||
return $conf . "\n";
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue