Skip to content
This repository has been archived by the owner on Dec 13, 2022. It is now read-only.

Commit

Permalink
fix(clapi): avoid to order parentship several times
Browse files Browse the repository at this point in the history
Refs: #6372
  • Loading branch information
kduret committed Jun 20, 2018
1 parent 570a997 commit fdbb834
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions www/class/centreon-clapi/centreonHost.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,6 @@ public function insertRelations($hostId)
$extended->insert(array($extended->getUniqueLabelField() => $hostId));
}


/**
* Del Action
* Must delete services as well
Expand Down Expand Up @@ -1172,7 +1171,6 @@ public function export($filterName = null)
$extendedObj = new \Centreon_Object_Host_Extended($this->dependencyInjector);
$macroObj = new \Centreon_Object_Host_Macro_Custom($this->dependencyInjector);
$instanceRel = new \Centreon_Object_Relation_Instance_Host($this->dependencyInjector);
$parentShip = array();

if ($this->register) {
$instElements = $instanceRel->getMergedParameters(
Expand All @@ -1186,6 +1184,13 @@ public function export($filterName = null)
"AND"
);
}

/* Init parentship */
$parentShip = array();
if ($this->register == 1) {
$parentShip = $this->getHostListByParent($elements);
}

foreach ($elements as $element) {
$addStr = $this->action . $this->delim . "ADD";
foreach ($this->insertParams as $param) {
Expand Down Expand Up @@ -1238,9 +1243,6 @@ public function export($filterName = null)
}

// Set parentship
if ($this->register == 1) {
$parentShip = $this->getHostListByParent($elements);
}
if (isset($parentShip[$element[$this->object->getPrimaryKey()]])) {
foreach ($parentShip[$element[$this->object->getPrimaryKey()]] as $parentId) {
echo $this->action . $this->delim
Expand Down

0 comments on commit fdbb834

Please sign in to comment.