Merge pull request #8061 from fappels/7.0_fix_module_builder

7.0 fix module builder
This commit is contained in:
Laurent Destailleur 2018-01-15 11:32:40 +01:00 committed by GitHub
commit 193dfec29e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 15 deletions

View File

@ -6221,7 +6221,7 @@ abstract class CommonObject
if (! empty($this->fields[$key]['foreignkey']) && $values[$key] == '-1') $values[$key]='';
//var_dump($key.'-'.$values[$key].'-'.($this->fields[$key]['notnull'] == 1));
if ($this->fields[$key]['notnull'] == 1 && empty($values[$key]))
if ($this->fields[$key]['notnull'] == 1 && ! isset($values[$key]))
{
$error++;
$this->errors[]=$langs->trans("ErrorFieldRequired", $this->fields[$key]['label']);
@ -6299,23 +6299,15 @@ abstract class CommonObject
$res = $this->db->query($sql);
if ($res)
{
if ($obj = $this->db->fetch_object($res))
$obj = $this->db->fetch_object($res);
if ($obj)
{
if ($obj)
{
$this->setVarsFromFetchObj($obj);
return $this->id;
}
else
{
return 0;
}
$this->setVarsFromFetchObj($obj);
return $this->id;
}
else
{
$this->error = $this->db->lasterror();
$this->errors[] = $this->error;
return -1;
return 0;
}
}
else

View File

@ -254,7 +254,7 @@ function rebuildObjectSql($destdir, $module, $objectname, $newmask, $readdir='',
$type = $val['type'];
$type = preg_replace('/:.*$/', '', $type); // For case type = 'integer:Societe:societe/class/societe.class.php'
if ($type == 'html') $type = 'text'; // html modulebuilder type is a text type in database
$texttoinsert.= "\t".$key." ".$type;
if ($key == 'rowid') $texttoinsert.= ' AUTO_INCREMENT PRIMARY KEY';
if ($key == 'entity') $texttoinsert.= ' DEFAULT 1';