I am getting the infamous Doctrine "PHP Rename Access Denied Code 5" error in my Symfony2 project when logging in using the User entity:
\\app\\cache\\dev/doctrine/orm/Proxies\\__CG__AcmeDemoBundleEntityUser.php): Access is denied. (code: 5)
I will log in OK, and if I am lucky, I can load a page before the session is killed as a result of the user authentication failing as a result of this error. It only happens with this one entity.
My colleague, with the same set up and same project has the same error but for a different entity (and ONLY that entity).
This problem has been reported on here before, with a link to the bug on Doctrine's GitHub which was confirmed fixed as of 2.5 (confirmed in Doctrine ORM 2.5 Release Notes).
My Symfony2 project is running with Doctrine ORM 2.5.4 yet I am still getting the same error.
Attempted Fixes
Reinstall XAMPP;
Deleted project & pulled project from git;
Updated vendor projects (maybe an old Doctrine ORM package remained);
Closing PHPStorm (maybe it's locking the files for indexing);
Disabled Windows indexing (same reason as above).
Changing the value of auto_generate_proxy_classes from %kernel.debug% to false in config_dev.yml prevents the problem, but this hides the issue instead of fixing it.
Has anyone managed to actually fix this?
Have you tried to set up auto_generate_proxy_classes to a underlying constant value for AbstractProxyFactory::AUTOGENERATE_EVAL or AbstractProxyFactory::AUTOGENERATE_FILE_NOT_EXISTS.
According to this documentation section Advanced Configuration > Auto-generating Proxy Classes this should fix the access denied problem in development environment.
Also, you should make sure your production configuration follows this recommendation:
In a production environment, it is highly recommended to use AUTOGENERATE_NEVER to allow for optimal performances. The other options are interesting in development environment.
Related
We have a project that has been in production for months (all its configs were working fine, no issues - including https and user access).
We rewrote part of code under Symfony 4 (no framework was used before that). Everything works perfectly on local, but, in production we started getting the following error in logs:
vendor/composer/ca-bundle/src/CaBundle.php is_dir(): open_basedir restriction in effect. File(/usr/local/etc/openssl) is not within the allowed path(s)
Any idea what might cause that (well... the error is obvious and one fix would be just to include that in allowed paths, but I don't want to do that until I understand the root cause of the problem)?
Important notes:
We did not include that particular bundle, is part of the composer.
Composer doesn't fail and no errors are received during composer install command.
The project SEEMS to work as expected despite the log line.
We have Cloudfare in front and https certificate is correcty handled there.
The list of used bundles is rather short but if needed I can provide a list.
We make no specific calls to functions from that bundle (if any are made, are made by something in symfony/3rd party bundles but a quick search in all code (including vendor) revealed nothing).
I'm kind of running out of ideas what might be causing the problem, especially since it doesn't happen on local and even in production the project seems OK.
The CA-bundle is trying to read from the usr/local/etc/openssl, and it fails because it's not in one of the allowed directories for the PHP process.
It happens in one machine and not in the other because your local openbase_dir settings do not match those in production (and are likely to be much lax, as it usually happens on development).
Your have two options:
Change your openbase_dir setting on production so it's more permissive, at least for that specific virtual-host.
Check which package you are installing depends on Ca-Bundle, and remove that package so it's no longer included.
Further reading:
How to set for specific directory open_basedir
Composer: how to know a package by what other package is required
I develop in symfony2 but am no sym2 wiz, brought in help to set everything up with the framework, and now it's throwing me a sudden error message I can't resolve.
I have two development environments, and one that I hadn't been using for a couple of months suddenly hit me with this error message upon trying to log in to my sym2 webapp locally:
"Erroneous data format for unserializing [user entity]"
I have not changed the code for logging in, I have not updated my vendors, and I have not changed any settings in MAMP (could it have updated itself though and done that?)
I don't understand what is going on.
I can google the error and I am suggested to hack one of the vendor source files. I would not know exactly what I would have done, so I am not comfortable with doing that just following some step-by-step instruction.
The application is running on symfony 2.3.9 and MAMP is set to PHP 5.6.27, the other option is 7.0.12 which produces the same error.
Ok, I changed my doctrine version to
"doctrine/orm": "~2.2,>=2.2.3,<2.5",
and it resolved the issue. Now I don't know what other issues THAT might have introduced seeing sym2 isn't always too backwards compatible, but fingers crossed =)
I have problem, after insert or update in my screen i see message:
Warning:
rename(C:\Users\Name\Desktop\BaseApp\var\cache\dev/doctrine/orm/Proxies__CG__AppBundleEntityCategory.php.57483ae07bdb29.50220410,C:\Users\Name\Desktop\BaseApp\var\cache\dev/doctrine/orm/Proxies__CG__AppBundleEntityCategory.php):
All time after update i see this message, after reload page all is right,
i use my app on windows, dev mode, symfony3,
Regards!
The problem is that the Doctrine's proxy class generation code doesn't handle concurrent requests very well. It works on Unix-like systems, but not on Windows, where you can't just rename over a file that is open.
See configuration of the doctrine bundle. You'll most like have auto_generate_proxy_classes set to "%kernel.debug%" (this is the default setting in symfony standard edition).
Try changing auto_generate_proxy_classes to false. You'll now have to manually clear the cache if you change your entities, but that error should be gone.
I don't know if this is a Symfony issue or a FOSUserBundle issue so I'll report here and hope get some help. I have two development instances:
CentOS 6.5, PHP 5.5.16, MySQL 5.5.37
CentOS 7, PHP 5.6.0, MariaDB 5.5.37
I tried the same project in both instances and by same project I mean the same: copied without any vendor and in both instances run "composer update" at first. After composer updates the vendor I tried to access admin area, which is handled by, FOSUserBundle and surprise in the first instance it works without any problem but in the second one it does not work and I get this error:
Error! Warning: Erroneous data format for unserializing
'Tanane\UserBundle\Entity\User' in
/var/www/html/tanane/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php
line 872
Can any give me some advice around this? Is a Symfony bug or a FOSUserBundle bug? Or it's other thing and I don't see it?
Yes, this is a known problem, though it's not in FOSUserBundle. This problem is caused by Doctrine 2, the deserialization is broken there on creating a ClassMetadataInfo.
However, fixing this problem involves introducing some incompatibilities in Doctrine's architecture, so this won't be fixed until Doctrine 2.5 release at least.
Currently, the options are to switch back to PHP 5.5 or less or use a master version of Doctrine (the pull request fixing this does not seem to be tagged yet)
See this Doctrine Jira ticket for more info.
I had a working Symfony2 application that uses several Sonata bundles (core, admin, doctrine-orm-admin, block). I have just pushed some revised code, and did a Composer update. Now, whilst app_dev.php seems to work fine, when I access the production version via app.php, I get an error;
Failed opening required 'vendor/sonata-project/easy-extends-bundle/Sonata/EasyExtendsBundle/SonataEasyExtendsBundle.php'
Looking in the vendors directory, the SonataEasyExtendsBundle.php is there, but it is in vendor/sonata-project/easy-extends-bundle, rather than in vendor/sonata-project/easy-extends-bundle/Sonata/EasyExtendsBundle/
Any ideas?
After much puzzling - it turned out to the APC cache. Clearing that resolved the issue. Doh.