Skip to content

Commit b0e11e8

Browse files
committed
bug symfony#35290 [Filesystem][FilesystemCommonTrait] Use a dedicated directory when there are no namespace (fancyweb)
This PR was merged into the 4.4 branch. Discussion ---------- [Filesystem][FilesystemCommonTrait] Use a dedicated directory when there are no namespace | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - This PR fixes the following edge case: - you use a namespaced filesystem adapter with root dir `/foo` and namespace `a`: all files are written in `/foo/a` (eg: it will write `/foo/a/b/file`) - you use another filesystem adapter with the same root dir but without namespace and you clear it. - it will fail because it will try to delete the `/foo/a/b` directory (see symfony#33921 new `scanHashDir()` method - `a` is a possible dir value (see `getFile()`) so we look for it). The simple solution (suggested by @nicolas-grekas) is to put the "empty namespace" in a dedicated directory. Bonus: that will fix the tests that currently always fail on AppVeyor. The file in the namespace `a` is a leftover from a previous test. Without this patch, I have the same fail on my Mac. I did not look why it currently passes on travis. Commits ------- eaa767b [Filesystem][FilesystemCommonTrait] Use a dedicated directory when there are no namespace
2 parents 84de1a3 + eaa767b commit b0e11e8

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/Symfony/Component/Cache/Traits/FilesystemCommonTrait.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ private function init(string $namespace, ?string $directory)
3535
throw new InvalidArgumentException(sprintf('Namespace contains "%s" but only characters in [-+_.A-Za-z0-9] are allowed.', $match[0]));
3636
}
3737
$directory .= \DIRECTORY_SEPARATOR.$namespace;
38+
} else {
39+
$directory .= \DIRECTORY_SEPARATOR.'@';
3840
}
3941
if (!file_exists($directory)) {
4042
@mkdir($directory, 0777, true);

0 commit comments

Comments
 (0)