diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index b624f20a0b3..18fe31aa4e2 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -7531,7 +7531,13 @@ abstract class CommonObject } elseif ($this->isDuration($info)) { // $this->{$field} may be null, '', 0, '0', 123, '123' - if ($this->{$field} != '' || !empty($info['notnull'])) $queryarray[$field] = (int) $this->{$field}; // If '0', it may be set to null later if $info['notnull'] == -1 + if ((isset($this->{$field}) && $this->{$field} != '') || !empty($info['notnull'])) { + if (!isset($this->{$field})) { + $queryarray[$field] = 0; + } else { + $queryarray[$field] = (int) $this->{$field}; // If '0', it may be set to null later if $info['notnull'] == -1 + } + } else $queryarray[$field] = null; } elseif ($this->isInt($info) || $this->isFloat($info)) {