mirror of
https://github.com/archtechx/tenancy.git
synced 2026-09-20 13:34:04 +00:00
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.
This commit is contained in:
parent
857c6fc233
commit
3ee5a8e426
1 changed files with 4 additions and 3 deletions
|
|
@ -238,14 +238,15 @@ class FilesystemTenancyBootstrapper implements TenancyBootstrapper
|
||||||
*/
|
*/
|
||||||
protected function tenantScopedPath(string $configuredPath, string $suffix): string
|
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);
|
$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.
|
// Swap the central storage path prefix for the tenant's.
|
||||||
// For example, storage_path('framework/cache/data') becomes storage_path('tenant1/framework/cache/data').
|
// For example, storage_path('framework/cache/data') becomes storage_path('tenant1/framework/cache/data').
|
||||||
return str($configuredPath)
|
return str($configuredPath)
|
||||||
->after($this->originalStoragePath . DIRECTORY_SEPARATOR)
|
->after($storagePath . DIRECTORY_SEPARATOR)
|
||||||
->prepend($this->tenantStoragePath($suffix) . DIRECTORY_SEPARATOR)
|
->prepend($this->tenantStoragePath($suffix) . DIRECTORY_SEPARATOR)
|
||||||
->toString();
|
->toString();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue