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) {