From f221342c092dc9c8a9663ddf04e14242123412ba Mon Sep 17 00:00:00 2001 From: Jephte Clain Date: Tue, 15 Jul 2025 16:50:24 +0400 Subject: [PATCH] =?UTF-8?q?support=20arr=C3=AAt=20de=20each()?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- php/src/db/CapacitorChannel.php | 5 +++-- php/src/db/CapacitorStorage.php | 4 +++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/php/src/db/CapacitorChannel.php b/php/src/db/CapacitorChannel.php index 0c2b370..3489203 100644 --- a/php/src/db/CapacitorChannel.php +++ b/php/src/db/CapacitorChannel.php @@ -366,13 +366,14 @@ class CapacitorChannel implements ITransactor { } /** - * méthode appelée lors du parcours des éléments avec - * {@link Capacitor::each()} + * méthode appelée lors du parcours des éléments avec {@link Capacitor::each()} * * @param ?array $row la ligne courante. l'élément courant est accessible via * $row["item"] * @return ?array le cas échéant, un tableau non null utilisé pour mettre à * jour la ligne courante + * Retourner [false] pour arrêter le parcours des éléments (la ligne courante + * ainsi que les autres lignes ne sont plus mise à jour) * * - Il est possible de mettre à jour $item en le retourant avec la clé "item" * - La clé primaire (il s'agit généralement de "id_") ne peut pas être diff --git a/php/src/db/CapacitorStorage.php b/php/src/db/CapacitorStorage.php index 65aa09c..f529839 100644 --- a/php/src/db/CapacitorStorage.php +++ b/php/src/db/CapacitorStorage.php @@ -661,7 +661,9 @@ abstract class CapacitorStorage { foreach ($rows as $row) { $rowIds = $this->getRowIds($channel, $row); $updates = $onEach->invoke([$row, ...$args]); - if (is_array($updates) && $updates) { + if ($updates === [false]) { + break; + } elseif ($updates !== null) { if (!array_key_exists("modified_", $updates)) { $updates["modified_"] = date("Y-m-d H:i:s"); }