From d7cd88e9c3ef54a8cce87a70169f029a211fcf9b Mon Sep 17 00:00:00 2001 From: Francis Appels Date: Fri, 18 Nov 2022 16:02:11 +0100 Subject: [PATCH] Revert "Make new method for fast scanlist optional (for the moment)." This reverts commit c034c1bb3359fa3a2ed8032b8046e98503edde8e. --- htdocs/product/list.php | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/htdocs/product/list.php b/htdocs/product/list.php index ae7be5009e1..e637e478df4 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -594,22 +594,20 @@ $sql .= $hookmanager->resPrint; //if (GETPOST("toolowstock")) $sql.= " HAVING SUM(s.reel) < p.seuil_stock_alerte"; // Not used yet $nbtotalofrecords = ''; -if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) { - if (!getDolGlobalInt('MAIN_ENABLE_FAST_SCANLIST')) { - $result = $db->query($sql); - $nbtotalofrecords = $db->num_rows($result); +if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { + /* $result = $db->query($sql); + $nbtotalofrecords = $db->num_rows($result); + */ + /* The fast and low memory method to get and count full list converts the sql into a sql count */ + $sqlforcount = preg_replace('/^SELECT[a-zA-Z0-9\._\s\(\),=<>\:\-\']+\sFROM/Ui', 'SELECT COUNT(*) as nbtotalofrecords FROM', $sql); + $sqlforcount = preg_replace('/'.preg_quote($linktopfp, '/').'/', '', $sqlforcount); + $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount); + $resql = $db->query($sqlforcount); + if ($resql) { + $objforcount = $db->fetch_object($resql); + $nbtotalofrecords = $objforcount->nbtotalofrecords; } else { - /* Experimental: The fast and low memory method to get and count full list converts the sql into a sql count */ - $sqlforcount = preg_replace('/^SELECT[a-zA-Z0-9\._\s\(\),=<>\:\-\']+\sFROM/Ui', 'SELECT COUNT(*) as nbtotalofrecords FROM', $sql); - $sqlforcount = preg_replace('/'.preg_quote($linktopfp, '/').'/', '', $sqlforcount); - $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount); - $resql = $db->query($sqlforcount); - if ($resql) { - $objforcount = $db->fetch_object($resql); - $nbtotalofrecords = $objforcount->nbtotalofrecords; - } else { - dol_print_error($db); - } + dol_print_error($db); } if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0