From 8513bc912afcc4dde31fd4cf2e26c1779d2d79aa Mon Sep 17 00:00:00 2001 From: omogenot Date: Sat, 16 Nov 2024 18:42:09 +0100 Subject: [PATCH] Allow multiple extrafields deletion If no element type parameter is given to the delete_label function, all occurences of the same extra field name are deleted at once. This simplifies the de-installation of a module that would have created multiple extra fields accros several element types. --- htdocs/core/class/extrafields.class.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 65dfd9a94f8f5..d31abac2706d7 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -619,8 +619,10 @@ private function delete_label($attrname, $elementtype = '') $sql = "DELETE FROM ".$this->db->prefix()."extrafields"; $sql .= " WHERE name = '".$this->db->escape($attrname)."'"; $sql .= " AND entity IN (0,".$conf->entity.')'; - $sql .= " AND elementtype = '".$this->db->escape($elementtype)."'"; - + if (!empty($elementtype)) { + $sql .= " AND elementtype = '".$this->db->escape($elementtype)."'"; + } + dol_syslog(get_class($this)."::delete_label", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) {