Skip to content


DCOM-234: Cache file fails on Windows - name too long #542

doctrinebot opened this Issue · 7 comments

6 participants


Jira issue originally created by user mattsnowboard:

The filename component of the FileCache is unbounded. It is possible to attempt to create files that are too long for the Windows filesystem. This causes an exception.

Example from a Symfony CMF/PHPCR project:

fileput_contents(D:\web_workspace\study\app\cache\dev\doctrine\cache\71d059fe39968db8\3e485dbb27419897\dfb24337887ff42c\a7b85c70bfefa781\nodes[nodes weak references cmsprogrampagesThe Summer ProgramThe Calendar 5 weeks for all Europe, routeContent, default][49] failed to open stream: Invalid argument in D:\webworkspace\study\vendor\doctrine\cache\lib\Doctrine\Common\Cache\FilesystemCache.php line 111

In this case, the ID was
"nodes[nodes weak references cmsprogrampagesThe Summer ProgramThe Calendar 5 weeks for all Europe, routeContent, default][49]"

That refers to a phpcr node:
cms/program/pages/The Summer Program/The Calendar 5 weeks for all Europe

Attempting to manually create that file in windows explorer shows that it is trunacted to
"nodes[nodes weak references cmsprogrampagesThe Summer ProgramThe Calendar 5 weeks for all Europe, routeContent, default][49].do" (128 characters)

Shouldn't the ID be truncated so this doesn't happen? Should this be fixed here or in the phpcr that is creating the long ID to begin with?


Comment created by mwe:

This is really an issue on windows. The Maximum path length is 260. (see

line 117:  // This ensures that the filename is unique and that there are no invalid chars in it.       
line 118: if ('' === $id || strlen($id ) > ((255 - strlen($this->extension)) / 2)) {

On windows, the directory has to be included:
with the following patch work fine. the 4 extra characters are for DIRECTORY_SEPARATOR (2 times) and for substr($hash, 0, 2):

line 117: if ('' === $id || strlen($id . $this->getDirectory() ) + 4 > ((255 - strlen($this->extension)) / 2)) {

I'v updated to Symfony 2.8 and ran in this problem.


Comment created by spicimedved:

Yes, I see the same problem on my Windows 10 notebook. I've just updated to Symfony 2.8 and Symfony is complaining that the cached annotation files connot be loaded.

See also this question

I can provide more detailed information if needed

@doctrinebot doctrinebot added the Bug label
@beberlei beberlei was assigned by doctrinebot

Agreed. Windows 10 environment also running into issues clearing the cache.

Failed to remove directory "F:\Dropbox\Symfony\Busybee\var\cache\dev_old\annotations\9f".

File Names like:

Looking forward to a fix. Symfony 3.


I'm suffering from the same problem.

The filenames within the annotation folders are too long for PHP+Windows. Doctrine will no delete the files because for PHP the files don't exist. After that, the directory cannot be remove because it's not empty.
I see two possible solutions: either the Dotrine cache filenames need to be shorter OR the remove() function the Symfony Filesystem component has to be improved to deal with these situations specifically on Windows.

In the meantime, is there any known workaround for this?

Doctrine member

The solution is for Doctrine IMO (and there is already a PR for that IIRC)

Doctrine member

Actually, doctrine/cache#107 has been merged already

@stof stof closed this
@beberlei beberlei was unassigned by Ocramius
@stof stof was assigned by Ocramius
@Ocramius Ocramius added the Invalid label

Hi @stof, thanks for the info!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.