From 60a37af39ad4174490dc23826aa54ea41a10a599 Mon Sep 17 00:00:00 2001 From: Kevin Duret Date: Fri, 6 Jul 2018 13:43:02 +0200 Subject: [PATCH] fix(clapi): avoid to order parentship several times (#6373) Refs: #6372 --- www/class/centreon-clapi/centreonHost.class.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/www/class/centreon-clapi/centreonHost.class.php b/www/class/centreon-clapi/centreonHost.class.php index df33a299beb..41317a44cb9 100644 --- a/www/class/centreon-clapi/centreonHost.class.php +++ b/www/class/centreon-clapi/centreonHost.class.php @@ -1126,7 +1126,6 @@ public function export($filters = null) $tpObj = new \Centreon_Object_Timeperiod(); $macroObj = new \Centreon_Object_Host_Macro_Custom(); $instanceRel = new \Centreon_Object_Relation_Instance_Host(); - $parentShip = array(); if ($this->register) { $instElements = $instanceRel->getMergedParameters( @@ -1141,6 +1140,12 @@ public function export($filters = null) ); } + /* 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) { @@ -1194,9 +1199,6 @@ public function export($filters = 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