From b7b18e3355aaecb52c64cafc1aa03775d2c90af4 Mon Sep 17 00:00:00 2001 From: Juanjo Menent Date: Fri, 7 Oct 2016 10:12:25 +0200 Subject: [PATCH] FIX: Error when CATEGORIE_RECURSIV_ADD is enabled and new category is daughter of an already linked to object --- htdocs/categories/class/categorie.class.php | 31 +++++++++++++-------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index e1e44a475ed..6202fe6eb0a 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -5,7 +5,7 @@ * Copyright (C) 2006-2012 Regis Houssin * Copyright (C) 2006-2012 Laurent Destailleur * Copyright (C) 2007 Patrick Raguin - * Copyright (C) 2013 Juanjo Menent + * Copyright (C) 2013-2016 Juanjo Menent * Copyright (C) 2013 Philippe Grand * Copyright (C) 2015 Marcos García * Copyright (C) 2015 Raphaël Doursenaud @@ -642,17 +642,24 @@ class Categorie extends CommonObject } else { - $this->db->rollback(); - if ($this->db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') - { - $this->error=$this->db->lasterrno(); - return -3; - } - else - { - $this->error=$this->db->lasterror(); - } - return -1; + if ($this->db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') + { + if (empty($conf->global->CATEGORIE_RECURSIV_ADD)) { + $this->db->rollback(); + $this->error = $this->db->lasterrno(); + return -3; + } + else { + $this->db->commit(); + return 1; + } + } + else + { + $this->db->rollback(); + $this->error=$this->db->lasterror(); + return -1; + } } }