From c30fb5d092e7f6c5c69d2880a10ca8feffa62e8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20=C5=A0tancl?= Date: Wed, 8 Jan 2025 10:11:04 +0100 Subject: [PATCH] fix 1267: early return in runForMultiple if an empty array is passed --- src/Tenancy.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Tenancy.php b/src/Tenancy.php index 7e509481..31947dbe 100644 --- a/src/Tenancy.php +++ b/src/Tenancy.php @@ -204,8 +204,10 @@ public function runForMultiple($tenants, Closure $callback): void // Wrap string in array $tenants = is_string($tenants) ? [$tenants] : $tenants; - // Use all tenants if $tenants is falsy - $tenants = $tenants ?: $this->model()->cursor(); // todo@phpstan phpstan thinks this isn't needed, but tests fail without it + // If $tenants is falsy by this point (e.g. an empty array) there's no work to be done + if (! $tenants) { + return; + } $originalTenant = $this->tenant;