From 3255c420ab4de197acee633bef7e3b0aab35cc0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 9 Nov 2022 14:45:26 +0100 Subject: [PATCH 1/3] delete extrafields when deleting ecmfiles --- htdocs/ecm/class/ecmfiles.class.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/htdocs/ecm/class/ecmfiles.class.php b/htdocs/ecm/class/ecmfiles.class.php index 3f4df8b847b..0e3f872cefd 100644 --- a/htdocs/ecm/class/ecmfiles.class.php +++ b/htdocs/ecm/class/ecmfiles.class.php @@ -751,7 +751,16 @@ class EcmFiles extends CommonObject } // If you need to delete child tables to, you can insert them here + if (!$error) { + $sql = "DELETE FROM " . $this->db->prefix() . $this->table_element. "_extrafields"; + $sql .= " WHERE fk_object = ".((int) $this->id); + $resql = $this->db->query($sql); + if (!$resql) { + $this->errors[] = $this->db->lasterror(); + $error++; + } + } if (!$error) { $sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element; $sql .= ' WHERE rowid='.((int) $this->id); From 1871872c1621944cdfbe5035e459c35604d1b132 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 9 Nov 2022 14:53:42 +0100 Subject: [PATCH 2/3] clean code --- htdocs/ecm/class/ecmfiles.class.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/htdocs/ecm/class/ecmfiles.class.php b/htdocs/ecm/class/ecmfiles.class.php index 0e3f872cefd..46d83cefaa8 100644 --- a/htdocs/ecm/class/ecmfiles.class.php +++ b/htdocs/ecm/class/ecmfiles.class.php @@ -752,11 +752,8 @@ class EcmFiles extends CommonObject // If you need to delete child tables to, you can insert them here if (!$error) { - $sql = "DELETE FROM " . $this->db->prefix() . $this->table_element. "_extrafields"; - $sql .= " WHERE fk_object = ".((int) $this->id); - - $resql = $this->db->query($sql); - if (!$resql) { + $result = $this->deleteExtraFields(); + if (!$result) { $this->errors[] = $this->db->lasterror(); $error++; } From ac5eb8b9ae77ea578299185b9319d5bc291e0aa0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 9 Nov 2022 14:55:41 +0100 Subject: [PATCH 3/3] clean code --- htdocs/ecm/class/ecmfiles.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/ecm/class/ecmfiles.class.php b/htdocs/ecm/class/ecmfiles.class.php index 46d83cefaa8..ab7b13aba90 100644 --- a/htdocs/ecm/class/ecmfiles.class.php +++ b/htdocs/ecm/class/ecmfiles.class.php @@ -754,7 +754,7 @@ class EcmFiles extends CommonObject if (!$error) { $result = $this->deleteExtraFields(); if (!$result) { - $this->errors[] = $this->db->lasterror(); + dol_syslog(get_class($this)."::delete error ".$this->error, LOG_ERR); $error++; } }