From 298e5cee61bc2ccc8a8def653f8a2415433e9d3b Mon Sep 17 00:00:00 2001 From: Juanjo Menent Date: Fri, 7 Oct 2016 22:21:50 +0200 Subject: [PATCH] Fix #5843 best way fixing --- htdocs/categories/class/categorie.class.php | 28 +++++++++++++-------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 6202fe6eb0a..410f0f80682 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -558,6 +558,7 @@ class Categorie extends CommonObject global $user,$langs,$conf; $error=0; + $trigger=true; if ($this->id == -1) return -2; @@ -598,12 +599,16 @@ class Categorie extends CommonObject { $cat = new Categorie($this->db); $cat->id=$objparent->fk_parent; - $result=$cat->add_type($obj, $type); - if ($result < 0) - { - $this->error=$cat->error; - $error++; - } + + if (! $cat->containsObject($type,$obj->id)) { + $result=$cat->add_type($obj, $type); + if ($result < 0) { + $this->error=$cat->error; + $error++; + } + } else { + $trigger=false; + } } } } @@ -624,10 +629,13 @@ class Categorie extends CommonObject $this->linkto=$obj; // Call trigger - $result=$this->call_trigger('CATEGORY_LINK',$user); - if ($result < 0) { $error++; } - // End call triggers - + if ($trigger) { + $result = $this->call_trigger('CATEGORY_LINK', $user); + if ($result < 0) { + $error++; + } + // End call triggers + } if (! $error) { $this->db->commit();