1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2025-12-12 11:14:04 +00:00

[4.x] Fix 1267: early return in runForMultiple if an empty array is passed (#1286)

* fix 1267: early return in runForMultiple if an empty array is passed

* Test that runForMulltiple runs the passed closure for the right tenants

* Correct comment

---------

Co-authored-by: lukinovec <lukinovec@gmail.com>
This commit is contained in:
Samuel Štancl 2025-02-14 08:19:02 +01:00 committed by GitHub
parent 25360f6b6a
commit 30ee4e9529
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 77 additions and 2 deletions

View file

@ -204,8 +204,10 @@ class Tenancy
// 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;