Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Access denied" error on 'rename' call when uploading files in Symfony

I'm working on a Symfony project in a Win7/Apache 2.2/ZendStudio environment and I have some trouble getting my file uploads to work properly.

My goal is to let the user create a new entity which can contain arbitrary many "Documents" (based on the article found at http://symfony.com/doc/current/cookbook/doctrine/file_uploads.html). I have a form type containing one field of type 'collection' (based on the article found at http://symfony.com/doc/current/cookbook/form/form_collections.html). So far so good. Via jQuery I can add arbitrarily many forms as subforms which works fine. But when I submit my form, very often (but not always!) I get the following exception:

Warning: rename(C:/Programming/Servers/Apache2.2/htdocs/Symfony/app/cache/dev/doctrine/orm/Proxies\__CG__MyMainBundleEntityRecruiter.php.507bf02e30df69.85090364,C:/Programming/Servers/Apache2.2/htdocs/Symfony/app/cache/dev/doctrine/orm/Proxies\__CG__MyMainBundleEntityLecture.php): Zugriff verweigert (code: 5) in C:\Programming\Servers\Apache2.2\htdocs\Symfony\vendor\doctrine\orm\lib\Doctrine\ORM\Proxy\ProxyFactory.php line 194

Zugriff verweigert is German for Access denied. Weirdly, the files seem to get renamed and saved at the right location nevertheless.

Why do I get this exception, does it have something to do with my environment and how can I fix it? I guess this issue is related to Symfony Warning : rename (../app/cache/dev , ../app/cache/dev_old ) : Access Denied . (Code : 5), but not quite sure whether it's the same as it happens in another context. I do also encounter the problem described in this link, though.

Thanks in advance.

like image 950
MichaelB Avatar asked Oct 15 '12 11:10

MichaelB


2 Answers

I've been running into the same exact issue recently. I don't really have a good sense of why the problem is happening, but the problem is coming from a step in the process where Doctrine is trying to generate proxy classes.

In my config.yml file, under the ORM section of the Doctrine configuration, I changed the value of auto_generate_proxy_classes from %kernel.debug% to false. I've played with it for a while since making the change and haven't been able to reproduce the issue since.

like image 102
dmccabe Avatar answered Sep 18 '22 14:09

dmccabe


Found this while looking for same answer, it seems to be a windows + Doctrine issue.

Doctrine Ticket with more detailed info

TLDR: Basically the proxy is trying to rename a file that's still being used, works in Linux but not always on windows.

like image 35
Suiko6272 Avatar answered Sep 17 '22 14:09

Suiko6272