From 3f169fb3b5dafa79ac422adc4f0d243ebcba0601 Mon Sep 17 00:00:00 2001 From: loiclau Date: Thu, 12 Oct 2017 12:07:07 +0200 Subject: [PATCH] fix(clapi) fix duplicate on stpl --- .../centreonServiceTemplate.class.php | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/www/class/centreon-clapi/centreonServiceTemplate.class.php b/www/class/centreon-clapi/centreonServiceTemplate.class.php index 8140f1e46ec..af72b93ea2b 100644 --- a/www/class/centreon-clapi/centreonServiceTemplate.class.php +++ b/www/class/centreon-clapi/centreonServiceTemplate.class.php @@ -752,11 +752,19 @@ public function __call($name, $arg) $relobj->delete(null, $serviceId); } - $existingRelationIds = $relobj->getTargetIdFromSourceId( - $relobj->getSecondKey(), - $relobj->getFirstKey(), - $serviceId - ); + if ((strtolower($matches[2]) === 'hosttemplate') && (strtolower($matches[1]) === 'add')) { + $existingRelationIds = $relobj->getTargetIdFromSourceId( + $relobj->getSecondKey(), + $relobj->getFirstKey(), + $serviceId + ); + } else { + $existingRelationIds = $relobj->getTargetIdFromSourceId( + $relobj->getFirstKey(), + $relobj->getSecondKey(), + $serviceId + ); + } foreach ($relationTable as $relationId) { if ($matches[1] == "del") {