Skip to content

Commit

Permalink
Allow multiple extrafields deletion
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
omogenot authored Nov 16, 2024
1 parent 3c3a119 commit 8513bc9
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions htdocs/core/class/extrafields.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)."'";
}

Check warning on line 625 in htdocs/core/class/extrafields.class.php

View workflow job for this annotation

GitHub Actions / phan / Run phan

extrafields.class.php: PhanPluginWhitespaceTrailing: The first occurrence of trailing whitespace was seen here.
dol_syslog(get_class($this)."::delete_label", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql) {
Expand Down

0 comments on commit 8513bc9

Please sign in to comment.