diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index af277ca7904..46122f6ff69 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -3930,8 +3930,8 @@ class CommandeFournisseurLigne extends CommonOrderLine $sql .= " WHERE rowid = ".((int) $this->id); dol_syslog(get_class($this)."::updateline", LOG_DEBUG); - $result = $this->db->query($sql); - if ($result) { + $resql = $this->db->query($sql); + if ($resql) { if (!$error) { $result = $this->insertExtraFields(); if ($result < 0) { @@ -3940,7 +3940,6 @@ class CommandeFournisseurLigne extends CommonOrderLine } if (!$error && !$notrigger) { - global $user; // Call trigger $result = $this->call_trigger('LINEORDER_SUPPLIER_MODIFY', $user); if ($result < 0) { diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index d2338bc28fb..1c7f8a31918 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -4240,7 +4240,7 @@ class Product extends CommonObject $sql = "SELECT MAX(rang) as max_rank FROM ".$this->db->prefix()."product_association"; $sql .= " WHERE fk_product_pere = ".((int) $id_pere); $resql = $this->db->query($sql); - if ($resql > 0) { + if ($resql) { $obj = $this->db->fetch_object($resql); $rank = $obj->max_rank + 1; //Addition of a product with the highest rank +1 diff --git a/test/phpunit/CodingPhpTest.php b/test/phpunit/CodingPhpTest.php index 194e615d72d..a7293657893 100644 --- a/test/phpunit/CodingPhpTest.php +++ b/test/phpunit/CodingPhpTest.php @@ -544,6 +544,16 @@ class CodingPhpTest extends PHPUnit\Framework\TestCase $this->assertTrue($ok, 'Found a preg_grep with a param that is a $var but without preg_quote in file '.$file['relativename'].'.'); + // Test we don't have "if ($resql >" + $ok=true; + $matches=array(); + preg_match_all('/if \(\$resql >/', $filecontent, $matches, PREG_SET_ORDER); + foreach ($matches as $key => $val) { + $ok=false; + break; + } + $this->assertTrue($ok, 'Found a if $resql with a > operator (when $resql is a boolean or resource) in file '.$file['relativename'].'. Please remove the > ... part.'); + // Test we don't have empty($user->hasRight $ok=true; $matches=array();