Skip to content

Commit

Permalink
fix 1267: early return in runForMultiple if an empty array is passed
Browse files Browse the repository at this point in the history
  • Loading branch information
stancl committed Jan 8, 2025
1 parent f955b38 commit c30fb5d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/Tenancy.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Check warning on line 209 in src/Tenancy.php

View check run for this annotation

Codecov / codecov/patch

src/Tenancy.php#L209

Added line #L209 was not covered by tests
}

$originalTenant = $this->tenant;

Expand Down

0 comments on commit c30fb5d

Please sign in to comment.