Skip to content

Commit

Permalink
FIX Extrafields always been delete and re insert for categories (#29781)
Browse files Browse the repository at this point in the history
* Check extrafields on the right table for categories

As it done in line 6737, it's necessary to add a compatibility renaming of table_element for categories.

* Update commonobject.class.php

* Update commonobject.class.php

---------

Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
  • Loading branch information
comaiteseb and eldy authored May 31, 2024
1 parent b08e260 commit a8781e0
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion htdocs/core/class/commonobject.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -7028,7 +7028,12 @@ public function updateExtraField($key, $trigger = null, $userused = null)
$linealreadyfound = 0;

// Check if there is already a line for this object (in most cases, it is, but sometimes it is not, for example when extra field has been created after), so we must keep this overload)
$sql = "SELECT COUNT(rowid) as nb FROM ".$this->db->prefix().$this->table_element."_extrafields WHERE fk_object = ".((int) $this->id);
$table_element = $this->table_element;
if ($table_element == 'categorie') { // TODO Rename table llx_categories_extrafields into llx_categorie_extrafields so we can remove this.
$table_element = 'categories'; // For compatibility
}

$sql = "SELECT COUNT(rowid) as nb FROM ".$this->db->prefix().$table_element."_extrafields WHERE fk_object = ".((int) $this->id);
$resql = $this->db->query($sql);
if ($resql) {
$tmpobj = $this->db->fetch_object($resql);
Expand Down

0 comments on commit a8781e0

Please sign in to comment.