From ae77c49985d2ce40119f951ede5f10105a81dd92 Mon Sep 17 00:00:00 2001 From: lukinovec Date: Wed, 19 Aug 2026 15:15:14 +0200 Subject: [PATCH] Stop requiring a root_override in possibleTenantSymlinks The symlink target used to be built from the root_override template, so a disk without an entry there had nothing to resolve. The symlink target is now the disk's tenant-context root, which the bootstrapper sets either way -- with a root_override it expands the template, without one, it appends the suffix to the disk's own root. Disks that only have a url_override now get a working symlink instead of being skipped while their URL was still overridden. Skipping disks with a null url_override is now explicit. The root_override check used to cover that by accident, and without it str_replace() gets null and throws a TypeError. --- assets/config.php | 2 +- src/Concerns/DealsWithTenantSymlinks.php | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/assets/config.php b/assets/config.php index 0403cfd1..96a0aeca 100644 --- a/assets/config.php +++ b/assets/config.php @@ -357,7 +357,7 @@ return [ * Use `php artisan tenants:link` to create a symbolic link from the tenant's storage to its public directory. */ 'url_override' => [ - // Note that the local disk you add must exist in the tenancy.filesystem.root_override config + // Note that the local disk you add must exist in the tenancy.filesystem.disks config 'public' => 'public-%tenant%', ], diff --git a/src/Concerns/DealsWithTenantSymlinks.php b/src/Concerns/DealsWithTenantSymlinks.php index 6ab4efc0..fcb9e432 100644 --- a/src/Concerns/DealsWithTenantSymlinks.php +++ b/src/Concerns/DealsWithTenantSymlinks.php @@ -18,7 +18,9 @@ trait DealsWithTenantSymlinks /** * Get all possible tenant symlinks, existing or not (array of ['public path' => 'disk root']). * - * Tenants can have a symlink for each disk registered in the tenancy.filesystem.url_override config. + * Tenants can have a symlink for each local disk that is listed + * in both tenancy.filesystem.disks and tenancy.filesystem.url_override. + * * This is used for creating all possible tenant symlinks and removing all existing tenant symlinks. * The same disk root can be symlinked to multiple public paths, which is why the public path * is the array key. @@ -29,7 +31,6 @@ trait DealsWithTenantSymlinks { $disks = config('filesystems.disks'); $urlOverrides = config('tenancy.filesystem.url_override'); - $rootOverrides = config('tenancy.filesystem.root_override'); $tenantKey = $tenant->getTenantKey(); $tenantDisks = tenancy()->run($tenant, fn () => config('filesystems.disks')); @@ -38,11 +39,12 @@ trait DealsWithTenantSymlinks $symlinks = []; foreach ($urlOverrides as $disk => $publicPath) { - if (! isset($disks[$disk])) { + if (! $publicPath) { + // The disk's URL is not overridden, same as in FilesystemTenancyBootstrapper::diskUrl() continue; } - if (! isset($rootOverrides[$disk])) { + if (! isset($disks[$disk])) { continue; } @@ -51,8 +53,8 @@ trait DealsWithTenantSymlinks } if (! in_array($disk, config('tenancy.filesystem.disks'), true)) { - // The bootstrapper only scopes disks listed in tenancy.filesystem.disks. Without that, - // the disk root stays central, and the symlink of every tenant would point to it. + // The bootstrapper only scopes disks listed in tenancy.filesystem.disks. + // Without that, the root stays central and the symlink of every tenant would point to it. throw new Exception("Disk $disk is not tenant-aware. Add it to the tenancy.filesystem.disks config to make its root tenant-specific."); }