Fix warning

This commit is contained in:
Laurent Destailleur 2020-12-16 12:53:31 +01:00
parent 371a460905
commit d781d78c4e
2 changed files with 3 additions and 2 deletions

View File

@ -312,7 +312,7 @@ class Categorie extends CommonObject
// Check parameters
if (empty($id) && empty($label) && empty($ref_ext)) return -1;
if (!is_numeric($type)) $type = $this->MAP_ID[$type];
if (!is_null($type) && !is_numeric($type)) $type = $this->MAP_ID[$type];
$sql = "SELECT rowid, fk_parent, entity, label, description, color, fk_soc, visible, type, ref_ext";
$sql .= ", date_creation, tms, fk_user_creat, fk_user_modif";
@ -1058,7 +1058,7 @@ class Categorie extends CommonObject
$current_lang = $langs->getDefaultLang();
// Init $this->cats array
$sql = "SELECT DISTINCT c.rowid, c.label, c.description, c.color, c.fk_parent, c.visible"; // Distinct reduce pb with old tables with duplicates
$sql = "SELECT DISTINCT c.rowid, c.label, c.ref_ext, c.description, c.color, c.fk_parent, c.visible"; // Distinct reduce pb with old tables with duplicates
if (!empty($conf->global->MAIN_MULTILANGS)) $sql .= ", t.label as label_trans, t.description as description_trans";
$sql .= " FROM ".MAIN_DB_PREFIX."categorie as c";
if (!empty($conf->global->MAIN_MULTILANGS)) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_lang as t ON t.fk_category=c.rowid AND t.lang='".$this->db->escape($current_lang)."'";

View File

@ -203,6 +203,7 @@ class CategorieTest extends PHPUnit\Framework\TestCase
$result=$localobject2->create($user);
$cat = new Categorie($this->savdb);
$cat->id = $catid;
$cat->type = 0;
$result=$cat->add_type($localobject2, "product");
print __METHOD__." result=".$result."\n";