From 065d715d4197b25ef7f262e498bd5b18afbe4b8b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 24 Oct 2018 02:20:07 +0200 Subject: [PATCH] FIX #9837 - The fetchAllXXX was not managing correctly the limit --- htdocs/accountancy/class/bookkeeping.class.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index 0550fb5a438..fe3ef196d1b 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -785,7 +785,8 @@ class BookKeeping extends CommonObject if ($resql) { $num = $this->db->num_rows($resql); - while ( $obj = $this->db->fetch_object($resql) ) { + $i = 0; + while ($obj = $this->db->fetch_object($resql) && (empty($limit) || $i < min($limit, $num))) { $line = new BookKeepingLine(); $line->id = $obj->rowid; @@ -817,6 +818,8 @@ class BookKeeping extends CommonObject $line->date_creation = $obj->date_creation; $this->lines[] = $line; + + $i++; } $this->db->free($resql); @@ -914,7 +917,8 @@ class BookKeeping extends CommonObject if ($resql) { $num = $this->db->num_rows($resql); - while ( $obj = $this->db->fetch_object($resql) ) { + $i = 0; + while ($obj = $this->db->fetch_object($resql) && (empty($limit) || $i < min($limit, $num))) { $line = new BookKeepingLine(); $line->id = $obj->rowid; @@ -943,6 +947,8 @@ class BookKeeping extends CommonObject $line->date_modification = $this->db->jdate($obj->date_modification); $this->lines[] = $line; + + $i++; } $this->db->free($resql); @@ -1021,7 +1027,7 @@ class BookKeeping extends CommonObject $num = $this->db->num_rows($resql); $i = 0; - while (($obj = $this->db->fetch_object($resql)) && ($i < min($limit, $num))) + while (($obj = $this->db->fetch_object($resql)) && (empty($limit) || $i < min($limit, $num))) { $line = new BookKeepingLine();