From 101c5a2dca5eff6739d9f9b48ece03f0d34d37c2 Mon Sep 17 00:00:00 2001 From: atm-florian Date: Tue, 30 Jan 2024 16:21:51 +0100 Subject: [PATCH 1/6] FIX 17.0 - php8 warnings: test for $field existence before checking if it is null or empty --- htdocs/core/class/commonobject.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 547f2b90e3d47..a2c07ecaf476b 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -9086,7 +9086,7 @@ public function setVarsFromFetchObj(&$obj) foreach ($this->fields as $field => $info) { if ($this->isDate($info)) { - if (is_null($obj->{$field}) || $obj->{$field} === '' || $obj->{$field} === '0000-00-00 00:00:00' || $obj->{$field} === '1000-01-01 00:00:00') { + if (!isset($obj->{$field}) || is_null($obj->{$field}) || $obj->{$field} === '' || $obj->{$field} === '0000-00-00 00:00:00' || $obj->{$field} === '1000-01-01 00:00:00') { $this->{$field} = ''; } else { $this->{$field} = $db->jdate($obj->{$field}); @@ -9102,7 +9102,7 @@ public function setVarsFromFetchObj(&$obj) $this->{$field} = (double) $obj->{$field}; } } else { - if (!is_null($obj->{$field}) || (isset($info['notnull']) && $info['notnull'] == 1)) { + if (isset($obj->{$field}) && (!is_null($obj->{$field}) || (isset($info['notnull']) && $info['notnull'] == 1))) { $this->{$field} = (int) $obj->{$field}; } else { $this->{$field} = null; @@ -9117,7 +9117,7 @@ public function setVarsFromFetchObj(&$obj) $this->{$field} = (double) $obj->{$field}; } } else { - if (!is_null($obj->{$field}) || (isset($info['notnull']) && $info['notnull'] == 1)) { + if (isset($obj->{$field}) && (!is_null($obj->{$field}) || (isset($info['notnull']) && $info['notnull'] == 1))) { $this->{$field} = (double) $obj->{$field}; } else { $this->{$field} = null; From fa104b6613d7aca2528cdf4b486f45f5198434ef Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Tue, 30 Jan 2024 17:55:13 +0100 Subject: [PATCH 2/6] automatic fixes --- htdocs/takepos/index.php | 40 +++++++++++++++++++++++++++++++++++----- 1 file changed, 35 insertions(+), 5 deletions(-) diff --git a/htdocs/takepos/index.php b/htdocs/takepos/index.php index c1fa77f91a2ba..9af1051b32de0 100644 --- a/htdocs/takepos/index.php +++ b/htdocs/takepos/index.php @@ -366,8 +366,18 @@ function LoadProducts(position, issubcat) { } ?> if (data[parseInt(idata)]['price_formated']) { - $("#proprice"+ishow).attr("class", "productprice"); - $("#proprice"+ishow).html(data[parseInt(idata)]['price_ttc_formated']); + $("#proprice" + ishow).attr("class", "productprice"); + + $("#proprice" + ishow).html(data[parseInt(idata)]['price_formated']); + + $("#proprice" + ishow).html(data[parseInt(idata)]['price_ttc_formated']); + } console.log("#prodiv"+ishow+".data(rowid)="+data[idata]['id']); console.log($("#prodiv"+ishow)); @@ -448,8 +458,18 @@ function MoreProducts(moreorless) { $("#probutton"+ishow).html(data[parseInt(idata)]['label']); $("#probutton"+ishow).show(); if (data[parseInt(idata)]['price_formated']) { - $("#proprice"+ishow).attr("class", "productprice"); - $("#proprice"+ishow).html(data[parseInt(idata)]['price_ttc_formated']); + $("#proprice" + ishow).attr("class", "productprice"); + + $("#proprice" + ishow).html(data[parseInt(idata)]['price_formated']); + + $("#proprice" + ishow).html(data[parseInt(idata)]['price_ttc_formated']); + } $("#proimg"+ishow).attr("src","genimg/index.php?query=pro&id="+data[idata]['id']); $("#prodiv"+ishow).data("rowid",data[idata]['id']); @@ -660,7 +680,17 @@ function Search2(keyCodeForEnter, moreorless) { $("#probutton" + i).show(); if (data[i]['price_formated']) { $("#proprice" + i).attr("class", "productprice"); - $("#proprice" + i).html(data[i]['price_ttc_formated']); + + $("#proprice" + i).html(data[i]['price_formated']); + + $("#proprice" + i).html(data[i]['price_ttc_formated']); + } $("#proimg" + i).attr("title", titlestring); if( undefined !== data[i]['img']) { From 8d9ddf4a51225eb9979a7cf58b0b5ca6cecf777f Mon Sep 17 00:00:00 2001 From: Eric Seigne Date: Tue, 30 Jan 2024 21:35:19 +0100 Subject: [PATCH 3/6] fix comment about datehour -> datetime --- htdocs/core/class/extrafields.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 1fbadc2ee8171..b685b36739697 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -221,7 +221,7 @@ public function __construct($db) * * @param string $attrname Code of attribute * @param string $label label of attribute - * @param string $type Type of attribute ('boolean','int','varchar','text','html','date','datehour','price','phone','mail','password','url','select','checkbox','separate',...) + * @param string $type Type of attribute ('boolean','int','varchar','text','html','date','datetime','price','phone','mail','password','url','select','checkbox','separate',...) * @param int $pos Position of attribute * @param string $size Size/length definition of attribute ('5', '24,8', ...). For float, it contains 2 numeric separated with a comma. * @param string $elementtype Element type. Same value than object->table_element (Example 'member', 'product', 'thirdparty', ...) @@ -287,7 +287,7 @@ public function addExtraField($attrname, $label, $type, $pos, $size, $elementtyp * This is a private method. For public method, use addExtraField. * * @param string $attrname code of attribute - * @param int $type Type of attribute ('boolean', 'int', 'varchar', 'text', 'html', 'date', 'datehour','price','phone','mail','password','url','select','checkbox', ...) + * @param int $type Type of attribute ('boolean', 'int', 'varchar', 'text', 'html', 'date', 'datetime','price','phone','mail','password','url','select','checkbox', ...) * @param string $length Size/length of attribute ('5', '24,8', ...) * @param string $elementtype Element type ('member', 'product', 'thirdparty', 'contact', ...) * @param int $unique Is field unique or not @@ -379,7 +379,7 @@ private function create($attrname, $type = 'varchar', $length = 255, $elementtyp * * @param string $attrname code of attribute * @param string $label label of attribute - * @param int $type Type of attribute ('int', 'varchar', 'text', 'html', 'date', 'datehour', 'float') + * @param int $type Type of attribute ('int', 'varchar', 'text', 'html', 'date', 'datetime', 'float') * @param int $pos Position of attribute * @param string $size Size/length of attribute ('5', '24,8', ...) * @param string $elementtype Element type ('member', 'product', 'thirdparty', ...) @@ -606,7 +606,7 @@ private function delete_label($attrname, $elementtype = 'member') * * @param string $attrname Name of attribute * @param string $label Label of attribute - * @param string $type Type of attribute ('boolean', 'int', 'varchar', 'text', 'html', 'date', 'datehour','price','phone','mail','password','url','select','checkbox', ...) + * @param string $type Type of attribute ('boolean', 'int', 'varchar', 'text', 'html', 'date', 'datetime','price','phone','mail','password','url','select','checkbox', ...) * @param int $length Length of attribute * @param string $elementtype Element type ('member', 'product', 'thirdparty', 'contact', ...) * @param int $unique Is field unique or not From 1f21e1a9456270a1e8ce94a35ecf1be39f6e25f7 Mon Sep 17 00:00:00 2001 From: Eric Seigne Date: Tue, 30 Jan 2024 21:42:57 +0100 Subject: [PATCH 4/6] fix #27883 : zero could be a value stored --- htdocs/core/lib/functions.lib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 7c0583519bdfb..9a4e951f377ee 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -51,7 +51,7 @@ function getDolGlobalString($key) { global $conf; // return $conf->global->$key ?? ''; - return (string) (empty($conf->global->$key) ? '' : $conf->global->$key); + return (string) (isset($conf->global->$key) ? $conf->global->$key : ''); } /** @@ -63,7 +63,7 @@ function getDolGlobalInt($key) { global $conf; // return $conf->global->$key ?? 0; - return (int) (empty($conf->global->$key) ? 0 : $conf->global->$key); + return (int) (isset($conf->global->$key) ? $conf->global->$key : 0); } /** From 39f3fe460641316b68c9eba8d2db3feec380252f Mon Sep 17 00:00:00 2001 From: ATM-Nicolas Date: Wed, 31 Jan 2024 10:59:22 +0100 Subject: [PATCH 5/6] FIX : Missing begin transaction when updating supplier recurring invoice --- htdocs/fourn/class/fournisseur.facture-rec.class.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/fourn/class/fournisseur.facture-rec.class.php b/htdocs/fourn/class/fournisseur.facture-rec.class.php index 015b467ec3e76..be7cb4adf2b5b 100644 --- a/htdocs/fourn/class/fournisseur.facture-rec.class.php +++ b/htdocs/fourn/class/fournisseur.facture-rec.class.php @@ -520,6 +520,8 @@ public function update(User $user, $notrigger = 0) $sql .= " auto_validate = ". (!empty($this->auto_validate) ? ((int) $this->auto_validate) : 0); $sql .= " WHERE rowid = ". (int) $this->id; + $this->db->begin(); + dol_syslog(get_class($this)."::update", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { From 318aed668dd884995258f33667f860ba87994bb2 Mon Sep 17 00:00:00 2001 From: ATM-Nicolas Date: Wed, 31 Jan 2024 11:24:37 +0100 Subject: [PATCH 6/6] FIX : SQL concatenation error --- htdocs/fourn/class/fournisseur.facture-rec.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.facture-rec.class.php b/htdocs/fourn/class/fournisseur.facture-rec.class.php index 015b467ec3e76..ec78d1fca1cc3 100644 --- a/htdocs/fourn/class/fournisseur.facture-rec.class.php +++ b/htdocs/fourn/class/fournisseur.facture-rec.class.php @@ -981,7 +981,7 @@ public function addline($fk_product, $ref, $label, $desc, $pu_ht, $pu_ttc, $qty, $sql .= ', fk_user_author'; $sql .= ', fk_multicurrency, multicurrency_code, multicurrency_subprice, multicurrency_total_ht, multicurrency_total_tva, multicurrency_total_ttc'; $sql .= ') VALUES ('; - $sql .= ' ' . (int) $facid; // source supplier invoie id + $sql .= ' ' . (int) $facid; // source supplier invoice id $sql .= ', ' . (!empty($fk_product) ? "'" . $this->db->escape($fk_product) . "'" : 'null'); $sql .= ', ' . (!empty($ref) ? "'" . $this->db->escape($ref) . "'" : 'null'); $sql .= ', ' . (!empty($label) ? "'" . $this->db->escape($label) . "'" : 'null'); @@ -1009,7 +1009,7 @@ public function addline($fk_product, $ref, $label, $desc, $pu_ht, $pu_ttc, $qty, $sql .= ', ' . (int) $special_code; $sql .= ', ' . (int) $rang; $sql .= ', ' . ($fk_unit ? (int) $fk_unit : 'NULL'); - $sql .= ', ' . (int) $user; + $sql .= ', ' . (int) $user->id; $sql .= ', ' . (int) $this->fk_multicurrency; $sql .= ", '" . $this->db->escape($this->multicurrency_code) . "'"; $sql .= ', ' . price2num($pu_ht_devise, 'CU'); @@ -2188,7 +2188,7 @@ public function update(User $user, $notrigger = 0) $sql .= ', special_code =' . (int) $this->special_code; $sql .= ', rang = ' . (int) $this->rang; $sql .= ', fk_unit = ' .($this->fk_unit ? "'".$this->db->escape($this->fk_unit)."'" : 'null'); - $sql .= ', fk_user_modif = ' . (int) $user; + $sql .= ', fk_user_modif = ' . (int) $user->id; $sql .= ' WHERE rowid = ' . (int) $this->id; $this->db->begin();