-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Prevent error because of too long paths #15547
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This is really a nice catch! A bit of related information:
Just a question: this solution works for your case, but what if DoctrineCacheBundle still generate too long paths even for the original |
@javiereguiluz AFAIK, the solution is to use PHP 5.6+ as I think they switched to the new API allowing longer path names |
@stof it's not only a limit on the PHP side, there also is a limit in the Windows system itself IIRC (had the same problem some time ago with NPM packages). |
@wouterj see what is quoted by @javiereguiluz: the limit depends on the API you use. AFAIK, node.js does not use the new API allowing longer paths to implement their IO functions, which is why they suffer from the limit too. I think PHP changed this (I'm not sure though) |
@stof Does this work for all Windows versions since Vista/7 or only Windows 8/10 ? |
@wouterj Can you rebase and push to get the tests running on Windows, also the current tests on Travis seem to be broken by this patch. |
@@ -54,7 +54,7 @@ protected function configure() | ||
protected function execute(InputInterface $input, OutputInterface $output) | ||
{ | ||
$realCacheDir = $this->getContainer()->getParameter('kernel.cache_dir'); | ||
$oldCacheDir = $realCacheDir.'_old'; | ||
$oldCacheDir = substr($realCacheDir, 0, -1).'_'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will break if the real cache dir is already suffixed with _
. So we need to make sure it's really different.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can move this to an else
below to save one substr call in the if
case
@wouterj Can you have a look at the failing tests? |
@wouterj could u rebase the PR please to see if tests pass? There is currently a strange failure |
Ok I've found the problem: The warmup dir and the old cache dir are now the same, so it doesn't work. |
Closing in favour of #16829 |
…ths (Tobion) This PR was merged into the 2.3 branch. Discussion ---------- [FrameworkBundle] prevent cache:clear creating too long paths | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #15547 #16783 | License | MIT | Doc PR | - Commits ------- 6e279c5 [FrameworkBundle] prevent cache:clear creating too long paths
On Windows, there is a maximum number of characters in a path. In a project on my PC, the DoctrineCacheBundle just didn't reach this maximum number in the
dev
directory. However, when clearing the cache, the directory was renamed todev_old
(4 characters longer). This means the command was unable to remove the directory (I had to rename the dir to something shorter and then remove it myself).This PR introduces a new name for the oldCacheDir, making sure it has the same length as the realCacheDir.