From 25b455272ab2ea91c80d35ac9286c5c0cc789a80 Mon Sep 17 00:00:00 2001 From: fappels Date: Sun, 14 Jan 2018 15:31:31 +0100 Subject: [PATCH 1/3] Fix 0 is a valif value for a NOT NULL field --- htdocs/core/class/commonobject.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 55abcee5699..1a8f7bc7bb9 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -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']); From d6ed968c516c6428aa7a0a6dd14d0abb55a643cb Mon Sep 17 00:00:00 2001 From: fappels Date: Sun, 14 Jan 2018 15:41:37 +0100 Subject: [PATCH 2/3] html modulebuilder type is a text type in database --- htdocs/core/lib/modulebuilder.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/modulebuilder.lib.php b/htdocs/core/lib/modulebuilder.lib.php index c437d47ce69..d14a60ab94f 100644 --- a/htdocs/core/lib/modulebuilder.lib.php +++ b/htdocs/core/lib/modulebuilder.lib.php @@ -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'; From 00185bd9d4b7c05e06b15bc24fd14d325648da95 Mon Sep 17 00:00:00 2001 From: fappels Date: Mon, 15 Jan 2018 11:21:24 +0100 Subject: [PATCH 3/3] Fix fetchCommon should return 0 iso error if not found --- htdocs/core/class/commonobject.class.php | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 1a8f7bc7bb9..d71277a77ee 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -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