From eead9a93d3209a0fde793e4297c9059ea5d6d053 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric?= <35066297+c3do@users.noreply.github.com> Date: Mon, 30 Mar 2020 13:03:13 +0200 Subject: [PATCH] Fix can set desiredstock to (int) 0 from API Rest When you set desiredstock to 0 as an integer from the API, it registers to null in the database. Using is_numeric() fixes this. --- htdocs/product/class/product.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 07aaf32cbb3..e47af8517de 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -763,7 +763,7 @@ class Product extends CommonObject $sql.= ", duration = '" . $this->db->escape($this->duration_value . $this->duration_unit) ."'"; $sql.= ", accountancy_code_buy = '" . $this->db->escape($this->accountancy_code_buy)."'"; $sql.= ", accountancy_code_sell= '" . $this->db->escape($this->accountancy_code_sell)."'"; - $sql.= ", desiredstock = " . ((isset($this->desiredstock) && $this->desiredstock != '') ? $this->desiredstock : "null"); + $sql.= ", desiredstock = " . ((isset($this->desiredstock) && is_numeric($this->desiredstock)) ? $this->desiredstock : "null"); $sql.= ", cost_price = " . ($this->cost_price != '' ? $this->db->escape($this->cost_price) : 'null'); $sql.= ", fk_unit= " . (!$this->fk_unit ? 'NULL' : $this->fk_unit); $sql.= ", price_autogen = " . (!$this->price_autogen ? 0 : 1);