From 131d1390bccdb03432e72395ca7b86c178f31ec8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 28 Sep 2025 22:20:44 +0200 Subject: [PATCH] Debug v23 --- .../class/api_subscriptions.class.php | 3 ++- htdocs/bom/class/api_boms.class.php | 5 ++-- htdocs/commande/class/api_orders.class.php | 6 +++-- .../bank/class/api_bankaccounts.class.php | 1 + .../facture/class/api_paiements.class.php | 3 ++- .../class/api_knowledgemanagement.class.php | 3 ++- .../template/class/api_mymodule.class.php | 3 ++- htdocs/mrp/class/api_mos.class.php | 5 ++-- .../class/api_partnerships.class.php | 3 ++- .../class/api_recruitments.class.php | 6 +++-- .../societe/class/api_thirdparties.class.php | 26 ++++++++++++++----- htdocs/ticket/class/api_tickets.class.php | 5 ++-- htdocs/user/class/api_users.class.php | 4 ++- htdocs/zapier/class/api_zapier.class.php | 4 ++- 14 files changed, 54 insertions(+), 23 deletions(-) diff --git a/htdocs/adherents/class/api_subscriptions.class.php b/htdocs/adherents/class/api_subscriptions.class.php index 18e55424e7a..b00f10a9123 100644 --- a/htdocs/adherents/class/api_subscriptions.class.php +++ b/htdocs/adherents/class/api_subscriptions.class.php @@ -139,7 +139,8 @@ class Subscriptions extends DolibarrApi if ($result) { $i = 0; $num = $this->db->num_rows($result); - while ($i < min($limit, $num)) { + $min = min($num, ($limit <= 0 ? $num : $limit)); + while ($i < $min) { $obj = $this->db->fetch_object($result); $subscription = new Subscription($this->db); if ($subscription->fetch($obj->rowid)) { diff --git a/htdocs/bom/class/api_boms.class.php b/htdocs/bom/class/api_boms.class.php index d1b0561cb73..20ce25bd279 100644 --- a/htdocs/bom/class/api_boms.class.php +++ b/htdocs/bom/class/api_boms.class.php @@ -164,9 +164,10 @@ class Boms extends DolibarrApi $result = $this->db->query($sql); if ($result) { - $num = $this->db->num_rows($result); $i = 0; - while ($i < $num) { + $num = $this->db->num_rows($result); + $min = min($num, ($limit <= 0 ? $num : $limit)); + while ($i < $min) { $obj = $this->db->fetch_object($result); $bom_static = new BOM($this->db); if ($bom_static->fetch($obj->rowid)) { diff --git a/htdocs/commande/class/api_orders.class.php b/htdocs/commande/class/api_orders.class.php index 92dee24651c..db8c279b575 100644 --- a/htdocs/commande/class/api_orders.class.php +++ b/htdocs/commande/class/api_orders.class.php @@ -1115,12 +1115,14 @@ class Orders extends DolibarrApi $result = $this->db->query($sql); if ($result) { + $i = 0; $num = $this->db->num_rows($result); if ($num <= 0) { throw new RestException(404, 'Shipments not found '); } - $i = 0; - while ($i < $num) { + //$min = min($num, ($limit <= 0 ? $num : $limit)); + $min = $num; + while ($i < $min) { $obj = $this->db->fetch_object($result); $shipment_static = new Expedition($this->db); if ($shipment_static->fetch($obj->rowid)) { diff --git a/htdocs/compta/bank/class/api_bankaccounts.class.php b/htdocs/compta/bank/class/api_bankaccounts.class.php index 842091a97aa..c57724c24f6 100644 --- a/htdocs/compta/bank/class/api_bankaccounts.class.php +++ b/htdocs/compta/bank/class/api_bankaccounts.class.php @@ -487,6 +487,7 @@ class BankAccounts extends DolibarrApi if ($result) { $num = $this->db->num_rows($result); + //$min = min($num, ($limit <= 0 ? $num : $limit)); for ($i = 0; $i < $num; $i++) { $obj = $this->db->fetch_object($result); $accountLine = new AccountLine($this->db); diff --git a/htdocs/compta/facture/class/api_paiements.class.php b/htdocs/compta/facture/class/api_paiements.class.php index b3d081e2583..540bb13e8bf 100644 --- a/htdocs/compta/facture/class/api_paiements.class.php +++ b/htdocs/compta/facture/class/api_paiements.class.php @@ -143,7 +143,8 @@ class Paiements extends DolibarrApi $i = 0; if ($result) { $num = $this->db->num_rows($result); - while ($i < $num) { + $min = min($num, ($limit <= 0 ? $num : $limit)); + while ($i < $min) { $obj = $this->db->fetch_object($result); $tmp_object = new Paiement($this->db); if ($tmp_object->fetch($obj->rowid)) { diff --git a/htdocs/knowledgemanagement/class/api_knowledgemanagement.class.php b/htdocs/knowledgemanagement/class/api_knowledgemanagement.class.php index 8f5bf236491..0a49beab845 100644 --- a/htdocs/knowledgemanagement/class/api_knowledgemanagement.class.php +++ b/htdocs/knowledgemanagement/class/api_knowledgemanagement.class.php @@ -208,7 +208,8 @@ class KnowledgeManagement extends DolibarrApi $i = 0; if ($result) { $num = $this->db->num_rows($result); - while ($i < $num) { + $min = min($num, ($limit <= 0 ? $num : $limit)); + while ($i < $min) { $obj = $this->db->fetch_object($result); $tmp_object = new KnowledgeRecord($this->db); if ($tmp_object->fetch($obj->rowid)) { diff --git a/htdocs/modulebuilder/template/class/api_mymodule.class.php b/htdocs/modulebuilder/template/class/api_mymodule.class.php index 93c9dd26499..09dda13e2d5 100644 --- a/htdocs/modulebuilder/template/class/api_mymodule.class.php +++ b/htdocs/modulebuilder/template/class/api_mymodule.class.php @@ -191,7 +191,8 @@ class MyModuleApi extends DolibarrApi $i = 0; if ($result) { $num = $this->db->num_rows($result); - while ($i < $num) { + $min = min($num, ($limit <= 0 ? $num : $limit)); + while ($i < $min) { $obj = $this->db->fetch_object($result); $tmp_object = new MyObject($this->db); if ($tmp_object->fetch($obj->rowid)) { diff --git a/htdocs/mrp/class/api_mos.class.php b/htdocs/mrp/class/api_mos.class.php index 6fb2532df67..be8130e19b0 100644 --- a/htdocs/mrp/class/api_mos.class.php +++ b/htdocs/mrp/class/api_mos.class.php @@ -156,9 +156,10 @@ class Mos extends DolibarrApi $result = $this->db->query($sql); if ($result) { - $num = $this->db->num_rows($result); $i = 0; - while ($i < $num) { + $num = $this->db->num_rows($result); + $min = min($num, ($limit <= 0 ? $num : $limit)); + while ($i < $min) { $obj = $this->db->fetch_object($result); $tmp_object = new Mo($this->db); if ($tmp_object->fetch($obj->rowid)) { diff --git a/htdocs/partnership/class/api_partnerships.class.php b/htdocs/partnership/class/api_partnerships.class.php index 119e2931a0f..60af4821d08 100644 --- a/htdocs/partnership/class/api_partnerships.class.php +++ b/htdocs/partnership/class/api_partnerships.class.php @@ -163,7 +163,8 @@ class Partnerships extends DolibarrApi $i = 0; if ($result) { $num = $this->db->num_rows($result); - while ($i < $num) { + $min = min($num, ($limit <= 0 ? $num : $limit)); + while ($i < $min) { $obj = $this->db->fetch_object($result); $tmp_object = new Partnership($this->db); if ($tmp_object->fetch($obj->rowid)) { diff --git a/htdocs/recruitment/class/api_recruitments.class.php b/htdocs/recruitment/class/api_recruitments.class.php index d8ec32e7405..628522d84c7 100644 --- a/htdocs/recruitment/class/api_recruitments.class.php +++ b/htdocs/recruitment/class/api_recruitments.class.php @@ -205,7 +205,8 @@ class Recruitments extends DolibarrApi $i = 0; if ($result) { $num = $this->db->num_rows($result); - while ($i < $num) { + $min = min($num, ($limit <= 0 ? $num : $limit)); + while ($i < $min) { $obj = $this->db->fetch_object($result); $tmp_object = new RecruitmentJobPosition($this->db); if ($tmp_object->fetch($obj->rowid)) { @@ -321,7 +322,8 @@ class Recruitments extends DolibarrApi $i = 0; if ($result) { $num = $this->db->num_rows($result); - while ($i < $num) { + $min = min($num, ($limit <= 0 ? $num : $limit)); + while ($i < $min) { $obj = $this->db->fetch_object($result); $tmp_object = new RecruitmentCandidature($this->db); if ($tmp_object->fetch($obj->rowid)) { diff --git a/htdocs/societe/class/api_thirdparties.class.php b/htdocs/societe/class/api_thirdparties.class.php index 4165ec90d54..e31a5198bc9 100644 --- a/htdocs/societe/class/api_thirdparties.class.php +++ b/htdocs/societe/class/api_thirdparties.class.php @@ -1130,7 +1130,7 @@ class Thirdparties extends DolibarrApi if (!$result) { throw new RestException(503, $this->db->lasterror()); } else { - $num = $this->db->num_rows($result); + //$num = $this->db->num_rows($result); while ($obj = $this->db->fetch_object($result)) { $obj_ret[] = $obj; } @@ -1447,8 +1447,11 @@ class Thirdparties extends DolibarrApi $notifications = array(); if ($result) { + $i = 0; $num = $this->db->num_rows($result); - while ($i < $num) { + //$min = min($num, ($limit <= 0 ? $num : $limit)); + $min = $num; + while ($i < $min) { $obj = $this->db->fetch_object($result); $notifications[] = $obj; $i++; @@ -1738,8 +1741,11 @@ class Thirdparties extends DolibarrApi $accounts = array(); if ($result) { + $i = 0; $num = $this->db->num_rows($result); - while ($i < $num) { + //$min = min($num, ($limit <= 0 ? $num : $limit)); + $min = $num; + while ($i < $min) { $obj = $this->db->fetch_object($result); $account = new CompanyBankAccount($this->db); @@ -1994,7 +2000,9 @@ class Thirdparties extends DolibarrApi } $num = $this->db->num_rows($result); - while ($i < $num) { + //$min = min($num, ($limit <= 0 ? $num : $limit)); + $min = $num; + while ($i < $min) { $obj = $this->db->fetch_object($result); $account = new CompanyBankAccount($this->db); @@ -2067,8 +2075,11 @@ class Thirdparties extends DolibarrApi $accounts = array(); + $i = 0; $num = $this->db->num_rows($result); - while ($i < $num) { + //$min = min($num, ($limit <= 0 ? $num : $limit)); + $min = $num; + while ($i < $min) { $obj = $this->db->fetch_object($result); $account = new SocieteAccount($this->db); @@ -2448,8 +2459,11 @@ class Thirdparties extends DolibarrApi } else { $i = 0; + $i = 0; $num = $this->db->num_rows($result); - while ($i < $num) { + //$min = min($num, ($limit <= 0 ? $num : $limit)); + $min = $num; + while ($i < $min) { $obj = $this->db->fetch_object($result); $account = new SocieteAccount($this->db); $account->fetch($obj->rowid); diff --git a/htdocs/ticket/class/api_tickets.class.php b/htdocs/ticket/class/api_tickets.class.php index 7e57fec4c49..ae29c769165 100644 --- a/htdocs/ticket/class/api_tickets.class.php +++ b/htdocs/ticket/class/api_tickets.class.php @@ -281,9 +281,10 @@ class Tickets extends DolibarrApi $result = $this->db->query($sql); if ($result) { - $num = $this->db->num_rows($result); $i = 0; - while ($i < $num) { + $num = $this->db->num_rows($result); + $min = min($num, ($limit <= 0 ? $num : $limit)); + while ($i < $min) { $obj = $this->db->fetch_object($result); $ticket_static = new Ticket($this->db); if ($ticket_static->fetch($obj->rowid)) { diff --git a/htdocs/user/class/api_users.class.php b/htdocs/user/class/api_users.class.php index ee63c835984..8d8678fe456 100644 --- a/htdocs/user/class/api_users.class.php +++ b/htdocs/user/class/api_users.class.php @@ -852,7 +852,9 @@ class Users extends DolibarrApi if ($result) { $num = $this->db->num_rows($result); - while ($i < $num) { + //$min = min($num, ($limit <= 0 ? $num : $limit)); + $min = $num; + while ($i < $min) { $obj = $this->db->fetch_object($result); $notifications[] = $obj; $i++; diff --git a/htdocs/zapier/class/api_zapier.class.php b/htdocs/zapier/class/api_zapier.class.php index 239a60b05e1..a09cc8000cf 100644 --- a/htdocs/zapier/class/api_zapier.class.php +++ b/htdocs/zapier/class/api_zapier.class.php @@ -185,8 +185,10 @@ class Zapier extends DolibarrApi $result = $this->db->query($sql); $i = 0; if ($result) { + $i = 0; $num = $this->db->num_rows($result); - while ($i < $num) { + $min = min($num, ($limit <= 0 ? $num : $limit)); + while ($i < $min) { $obj = $this->db->fetch_object($result); $hook_static = new Hook($this->db); if ($hook_static->fetch($obj->rowid)) {