diff --git a/src/Bootstrappers/FilesystemTenancyBootstrapper.php b/src/Bootstrappers/FilesystemTenancyBootstrapper.php index 16721e27..413210ac 100644 --- a/src/Bootstrappers/FilesystemTenancyBootstrapper.php +++ b/src/Bootstrappers/FilesystemTenancyBootstrapper.php @@ -339,7 +339,7 @@ class FilesystemTenancyBootstrapper implements TenancyBootstrapper * Note that the returned path doesn't depend on suffix_storage_path. * That config option only affects the storage_path() helper. */ - public static function getBoundTenantStoragePath(Tenant $tenant): string + public static function getTenantStoragePath(Tenant $tenant): string { $bootstrapper = app(static::class); @@ -349,7 +349,7 @@ class FilesystemTenancyBootstrapper implements TenancyBootstrapper /** * Name of the disk whose root the passed disk uses. * - * Disks using the 'scoped' driver have no root or url of their own -- they inherit these from their parent disk, + * Disks using the 'scoped' driver have no root or url of their own -- they inherit those from their parent disk, * which can be scoped as well, so only the final/base parent has to be tenant-aware. * * Returns null if the chain doesn't end with a named disk, i.e. when a parent disk is @@ -362,12 +362,14 @@ class FilesystemTenancyBootstrapper implements TenancyBootstrapper while (config("filesystems.disks.$disk.driver") === 'scoped') { if (in_array($disk, $visited, true)) { + // The disk and its parents reference each other, invalid return null; } $visited[] = $disk; + $disk = config("filesystems.disks.$disk.disk"); - if (! is_string($disk = config("filesystems.disks.$disk.disk"))) { + if (! is_string($disk)) { // Laravel allows configuring the parent disk inline as an array, and such a disk has no name return null; } diff --git a/src/Bootstrappers/LogChannelBootstrapper.php b/src/Bootstrappers/LogChannelBootstrapper.php index 36ed32f9..0d4ddfd0 100644 --- a/src/Bootstrappers/LogChannelBootstrapper.php +++ b/src/Bootstrappers/LogChannelBootstrapper.php @@ -151,12 +151,12 @@ class LogChannelBootstrapper implements TenancyBootstrapper // The tenant log will be located at e.g. "storage/tenant{$tenantKey}/logs/laravel.log". $originalChannelPath = $this->config->get("logging.channels.{$channel}.path"); $centralStoragePath = FilesystemTenancyBootstrapper::getBoundCentralStoragePath(); - $tenantStoragePath = FilesystemTenancyBootstrapper::getBoundTenantStoragePath($tenant); + $tenantStoragePath = FilesystemTenancyBootstrapper::getTenantStoragePath($tenant); // The tenant log will inherit the segment that follows the storage path from the central channel path config. // For example, if a channel's path is configured to storage_path('logs/foo.log') (storage/logs/foo.log), // the '/logs/foo.log' segment will be placed within the tenant storage path (so the log will be located at storage/tenant123/logs/foo.log). - $this->config->set("logging.channels.{$channel}.path", $tenantStoragePath . Str::after($originalChannelPath, $centralStoragePath)); + $this->config->set("logging.channels.{$channel}.path", $tenantStoragePath . Str::after($originalChannelPath, rtrim($centralStoragePath, '/\\'))); } } } diff --git a/src/Controllers/TenantAssetController.php b/src/Controllers/TenantAssetController.php index 20ff6f99..33799b29 100644 --- a/src/Controllers/TenantAssetController.php +++ b/src/Controllers/TenantAssetController.php @@ -121,7 +121,7 @@ class TenantAssetController implements HasMiddleware } if ($tenant = tenant()) { - return FilesystemTenancyBootstrapper::getBoundTenantStoragePath($tenant) . '/app/public'; + return FilesystemTenancyBootstrapper::getTenantStoragePath($tenant) . '/app/public'; } return storage_path('app/public'); diff --git a/src/Jobs/DeleteTenantStorage.php b/src/Jobs/DeleteTenantStorage.php index d8161be1..7245c4d0 100644 --- a/src/Jobs/DeleteTenantStorage.php +++ b/src/Jobs/DeleteTenantStorage.php @@ -34,7 +34,7 @@ class DeleteTenantStorage implements ShouldQueue public function handle(): void { - $tenantStoragePath = FilesystemTenancyBootstrapper::getBoundTenantStoragePath($this->tenant); + $tenantStoragePath = FilesystemTenancyBootstrapper::getTenantStoragePath($this->tenant); $centralStoragePath = FilesystemTenancyBootstrapper::getBoundCentralStoragePath(); if (realpath($tenantStoragePath) === realpath($centralStoragePath)) {