Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

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

Closed
wants to merge 2 commits into from
Closed

Conversation

wouterj
Copy link
Member

@wouterj wouterj commented Aug 14, 2015

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 to dev_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.

Q A
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets -
License MIT
Doc PR -

@javiereguiluz
Copy link
Member

This is really a nice catch!

A bit of related information:

In the Windows API (with some exceptions discussed in the following paragraphs), the maximum length for a path is MAX_PATH, which is defined as 260 characters.

The Windows API has many functions that also have Unicode versions to permit an extended-length path for a maximum total path length of 32,767 characters.

Source

Just a question: this solution works for your case, but what if DoctrineCacheBundle still generate too long paths even for the original dev/ folder?

@stof
Copy link
Member

stof commented Aug 14, 2015

@javiereguiluz AFAIK, the solution is to use PHP 5.6+ as I think they switched to the new API allowing longer path names

@wouterj
Copy link
Member Author

wouterj commented Aug 14, 2015

@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).

@stof
Copy link
Member

stof commented Aug 14, 2015

@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)

@sstok
Copy link
Contributor

sstok commented Aug 14, 2015

@stof Does this work for all Windows versions since Vista/7 or only Windows 8/10 ?

@fabpot
Copy link
Member

fabpot commented Sep 14, 2015

@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).'_';
Copy link
Contributor

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Copy link
Contributor

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

@fabpot
Copy link
Member

fabpot commented Oct 1, 2015

@wouterj Can you have a look at the failing tests?

@Tobion
Copy link
Contributor

Tobion commented Dec 3, 2015

@wouterj could u rebase the PR please to see if tests pass? There is currently a strange failure CacheClearCommandTest::testCacheIsFreshAfterCacheClearedWithWarmup

@Tobion
Copy link
Contributor

Tobion commented Dec 4, 2015

Ok I've found the problem: The warmup dir and the old cache dir are now the same, so it doesn't work.

@Tobion
Copy link
Contributor

Tobion commented Dec 4, 2015

Closing in favour of #16829

@Tobion Tobion closed this Dec 4, 2015
@wouterj wouterj deleted the patch-12 branch December 4, 2015 10:17
Tobion added a commit that referenced this pull request Dec 10, 2015
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.