1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2026-09-20 20:24:03 +00:00

Throw an exception if a scoped disk is listed in tenant-aware disks without its base disk

In FSBootstrapper::forgetDisks():
- `tenancy.filesystem.disks => ['scoped']` throws
- `tenancy.filesystem.disks => ['scoped', 'parent']` does NOT throw
- `tenancy.filesystem.disks => ['scoped_with_scoped_parent', 'scoped_parent']` (invalid config where a scoped disk's base disk doesn't actually exist because the scoped disks just reference themselves) throws
This commit is contained in:
lukinovec 2026-09-07 11:04:29 +02:00 committed by Samuel Stancl
parent e7c0193931
commit dde9be6f58
2 changed files with 57 additions and 5 deletions

View file

@ -128,10 +128,16 @@ class FilesystemTenancyBootstrapper implements TenancyBootstrapper
$scopedDisks = [];
foreach ($this->app['config']['filesystems.disks'] as $name => $disk) {
if (isset($disk['driver'])
&& $disk['driver'] === 'scoped'
&& in_array(static::baseDiskName($name), $tenantDisks, true)) {
if (($disk['driver'] ?? null) !== 'scoped') {
continue;
}
$baseDisk = static::baseDiskName($name);
if (in_array($baseDisk, $tenantDisks, true)) {
$scopedDisks[] = $name;
} elseif (in_array($name, $tenantDisks, true)) {
throw new Exception("A disk using the 'scoped' driver cannot be tenant-aware. List its base disk in tenancy.filesystem.disks instead.");
}
}
@ -142,6 +148,7 @@ class FilesystemTenancyBootstrapper implements TenancyBootstrapper
{
if ($this->app['config']["filesystems.disks.$disk.driver"] === 'scoped') {
// Skip scoped disks since they have no root to override
// (reachable when a scoped disk is listed in tenancy.filesystem.disks alongside its base disk).
return;
}