From 8196134345bd539c0f48674950110f39ed0228eb Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 27 Jan 2022 14:17:14 +0100 Subject: [PATCH] FIX not use $this in static function --- htdocs/core/class/html.form.class.php | 8 +++++--- htdocs/product/class/productbatch.class.php | 14 +++++++------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 00a12ad9965..91c45055296 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -7388,6 +7388,8 @@ class Form */ protected static function forgeCriteriaCallback($matches) { + global $db; + //dol_syslog("Convert matches ".$matches[1]); if (empty($matches[1])) { return ''; @@ -7400,11 +7402,11 @@ class Form $tmpescaped = $tmp[2]; $regbis = array(); if (preg_match('/^\'(.*)\'$/', $tmpescaped, $regbis)) { - $tmpescaped = "'".$this->db->escape($regbis[1])."'"; + $tmpescaped = "'".$db->escape($regbis[1])."'"; } else { - $tmpescaped = $$this->db->escape($tmpescaped); + $tmpescaped = $db->escape($tmpescaped); } - return $$this->db->escape($tmp[0]).' '.strtoupper($$this->db->escape($tmp[1]))." ".$tmpescaped; + return $db->escape($tmp[0]).' '.strtoupper($db->escape($tmp[1]))." ".$tmpescaped; } /** diff --git a/htdocs/product/class/productbatch.class.php b/htdocs/product/class/productbatch.class.php index 4a8233a61eb..5149dd2c708 100644 --- a/htdocs/product/class/productbatch.class.php +++ b/htdocs/product/class/productbatch.class.php @@ -436,7 +436,7 @@ class Productbatch extends CommonObject */ public static function findAll($db, $fk_product_stock, $with_qty = 0, $fk_product = 0) { - global $langs, $conf; + global $conf; $ret = array(); @@ -453,9 +453,9 @@ class Productbatch extends CommonObject $sql .= ", pl.rowid as lotid, pl.eatby as eatby, pl.sellby as sellby"; // TODO May add extrafields to ? } - $sql .= " FROM ".$this->db->prefix()."product_batch as t"; + $sql .= " FROM ".$db->prefix()."product_batch as t"; if ($fk_product > 0) { - $sql .= " LEFT JOIN ".$this->db->prefix()."product_lot as pl ON pl.fk_product = ".((int) $fk_product)." AND pl.batch = t.batch"; + $sql .= " LEFT JOIN ".$db->prefix()."product_lot as pl ON pl.fk_product = ".((int) $fk_product)." AND pl.batch = t.batch"; // TODO May add extrafields to ? } $sql .= " WHERE fk_product_stock=".((int) $fk_product_stock); @@ -526,10 +526,10 @@ class Productbatch extends CommonObject $sql .= ", pl.sellby"; $sql .= ", pl.eatby"; $sql .= ", pb.qty"; - $sql .= " FROM ".$this->db->prefix()."product_lot as pl"; - $sql .= " LEFT JOIN ".$this->db->prefix()."product as p ON p.rowid = pl.fk_product"; - $sql .= " LEFT JOIN ".$this->db->prefix()."product_batch AS pb ON pl.batch = pb.batch"; - $sql .= " LEFT JOIN ".$this->db->prefix()."product_stock AS ps ON ps.rowid = pb.fk_product_stock"; + $sql .= " FROM ".$db->prefix()."product_lot as pl"; + $sql .= " LEFT JOIN ".$db->prefix()."product as p ON p.rowid = pl.fk_product"; + $sql .= " LEFT JOIN ".$db->prefix()."product_batch AS pb ON pl.batch = pb.batch"; + $sql .= " LEFT JOIN ".$db->prefix()."product_stock AS ps ON ps.rowid = pb.fk_product_stock"; $sql .= " WHERE p.entity IN (".getEntity('product').")"; $sql .= " AND pl.fk_product = ".((int) $fk_product); if ($fk_warehouse > 0) {