FIX better test for all usage

This commit is contained in:
Regis Houssin 2022-03-24 20:26:47 +01:00
parent c38437f0de
commit 391c02993d

View File

@ -4422,8 +4422,10 @@ abstract class CommonObject
$langs->load("errors");
//print 'Found into table '.$table.', type '.$langs->transnoentitiesnoconv($elementname).', haschild='.$haschild;
$haschild += $obj->nb;
if (is_numeric($element) || empty($element['name'])) { // old usage
if (is_numeric($element)) { // very old usage array('table1', 'table2', ...)
$this->errors[] = $langs->transnoentitiesnoconv("ErrorRecordHasAtLeastOneChildOfType", method_exists($this, 'getNomUrl') ? $this->getNomUrl() : $this->ref, $table);
} elseif (is_string($element)) { // old usage array('table1' => 'TranslateKey1', 'table2' => 'TranslateKey2', ...)
$this->errors[] = $langs->transnoentitiesnoconv("ErrorRecordHasAtLeastOneChildOfType", method_exists($this, 'getNomUrl') ? $this->getNomUrl() : $this->ref, $langs->transnoentitiesnoconv($element));
} else { // new usage: $element['name']=Translation key
$this->errors[] = $langs->transnoentitiesnoconv("ErrorRecordHasAtLeastOneChildOfType", method_exists($this, 'getNomUrl') ? $this->getNomUrl() : $this->ref, $langs->transnoentitiesnoconv($element['name']));
}