From 3ee5a8e42635aefc7ec75241e6129effcd758de0 Mon Sep 17 00:00:00 2001 From: lukinovec Date: Wed, 26 Aug 2026 17:40:14 +0200 Subject: [PATCH] Normalize the original storage path in tenantScopedPath too Same as $configuredPath, $originalStoragePath isn't guaranteed to use OS separators either. On Windows, a storage path like 'C:/app/storage' would make the str_starts_with check return false even if true was expected. Note that configuring the storage path to use '/' on Windows sounds very unlikely -- implementing this primarily for symmetry with $configuredPath. --- src/Bootstrappers/FilesystemTenancyBootstrapper.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Bootstrappers/FilesystemTenancyBootstrapper.php b/src/Bootstrappers/FilesystemTenancyBootstrapper.php index c91e7f98..743a1c49 100644 --- a/src/Bootstrappers/FilesystemTenancyBootstrapper.php +++ b/src/Bootstrappers/FilesystemTenancyBootstrapper.php @@ -238,14 +238,15 @@ class FilesystemTenancyBootstrapper implements TenancyBootstrapper */ protected function tenantScopedPath(string $configuredPath, string $suffix): string { - // Normalize the path to use the separator of the current OS. + // Normalize the paths to use the separator of the current OS. $configuredPath = str_replace('/', DIRECTORY_SEPARATOR, $configuredPath); + $storagePath = str_replace('/', DIRECTORY_SEPARATOR, $this->originalStoragePath); - if (str_starts_with($configuredPath, $this->originalStoragePath . DIRECTORY_SEPARATOR)) { + if (str_starts_with($configuredPath, $storagePath . DIRECTORY_SEPARATOR)) { // Swap the central storage path prefix for the tenant's. // For example, storage_path('framework/cache/data') becomes storage_path('tenant1/framework/cache/data'). return str($configuredPath) - ->after($this->originalStoragePath . DIRECTORY_SEPARATOR) + ->after($storagePath . DIRECTORY_SEPARATOR) ->prepend($this->tenantStoragePath($suffix) . DIRECTORY_SEPARATOR) ->toString(); }