Skip to content

Commit

Permalink
NEW: Allow multiple extrafields deletion (#31956)
Browse files Browse the repository at this point in the history
* 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.

* Update extrafields.class.php

Remove empty line whitespace
  • Loading branch information
omogenot authored Nov 16, 2024
1 parent a811e06 commit 48f0f55
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion htdocs/core/class/extrafields.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,9 @@ 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);
Expand Down

0 comments on commit 48f0f55

Please sign in to comment.