mirror of
https://github.com/archtechx/tenancy.git
synced 2026-09-20 13:34:04 +00:00
Revert tenantScopedPath changes
Revert the function to its pre-127945190ee60cba00e81dbf6bab3133495428a3 state. Even though in that state, we were returning the normalized path, which isn't correct, it handled the possible edge cases better (better than we could handle them with the proposed change of the version of this method before this commit anyway), and was overall more sound.
This commit is contained in:
parent
127945190e
commit
0461697e6d
1 changed files with 8 additions and 6 deletions
|
|
@ -238,20 +238,22 @@ class FilesystemTenancyBootstrapper implements TenancyBootstrapper
|
||||||
*/
|
*/
|
||||||
protected function tenantScopedPath(string $configuredPath, string $suffix): string
|
protected function tenantScopedPath(string $configuredPath, string $suffix): string
|
||||||
{
|
{
|
||||||
$centralPath = rtrim($this->originalStoragePath, '/\\');
|
// 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($configuredPath)->startsWith([$centralPath . '/', $centralPath . '\\'])) {
|
if (str_starts_with($configuredPath, $storagePath . DIRECTORY_SEPARATOR)) {
|
||||||
// Swap the central storage path prefix for the tenant's, keeping the configured separators.
|
// 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($centralPath)
|
->after($storagePath . DIRECTORY_SEPARATOR)
|
||||||
->prepend($this->tenantStoragePath($suffix))
|
->prepend($this->tenantStoragePath($suffix) . DIRECTORY_SEPARATOR)
|
||||||
->toString();
|
->toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Otherwise $configuredPath isn't necessarily storage_path()-based, so just append the
|
// Otherwise $configuredPath isn't necessarily storage_path()-based, so just append the
|
||||||
// suffix as a subdirectory, e.g. '/var/cache/foo' becomes '/var/cache/foo/tenant1'.
|
// suffix as a subdirectory, e.g. '/var/cache/foo' becomes '/var/cache/foo/tenant1'.
|
||||||
return rtrim($configuredPath, '/\\') . DIRECTORY_SEPARATOR . $suffix;
|
return rtrim($configuredPath, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $suffix;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function scopeSessions(string|false $suffix): void
|
public function scopeSessions(string|false $suffix): void
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue