Closed
Description
Q | A |
---|---|
Bug report? | yes |
Feature request? | no |
BC Break report? | no |
RFC? | no |
Symfony version | 3.4.* |
PHP version | 5.6.25 |
We're currently upgrading a Symfony project to 3.4 on PHP 5.6.25 and my colleague has been having this issue since I've added the following block of code to our AppKernel::registerContainerConfiguration
method:
$loader->load(function (ContainerBuilder $container) {
$container->setParameter('container.autowiring.strict_mode', true);
$container->setParameter('container.dumper.inline_class_loader', true);
$container->addObjectResource($this);
});
It only happened on a second request, and often it had to be a different request, not just the same one (aka refresh didn’t cause it).
He found two ways to make it work :
- Commenting out the line
$container->setParameter('container.dumper.inline_class_loader', true);
, or - Commenting out the line
$kernel->loadClassCache();
inapp_dev.php
I personally can't reproduce the issue on my setup. Any idea what might be happening here ?
Also, it might look like we're not the only ones : https://stackoverflow.com/questions/47617879/symfony-duplicate-class-definition-in-cache
Thanks for your help.
gnutix
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
rpac-tump commentedon Dec 5, 2017
His 1st way is ok for me, i can refresh without error.
The solution on stackoverflow doesn't work for now...
nicolas-grekas commentedon Dec 5, 2017
I think you need to remove this line from app*.php:
https://github.com/symfony/symfony-standard/blob/3.3/web/app.php#L7
nicolas-grekas commentedon Dec 5, 2017
Try also removing L12 btw (loadClassCache)
gnutix commentedon Dec 5, 2017
@nicolas-grekas That's indeed the second solution he found. However, I'm wondering why it happens and if it's a good idea to release standard code for Symfony that provoke this issue. I don't know the caching mechanism in details, but I guess there's an impact on performance for both solutions (disabling the inline dumper or the loadCacheClass) ?
I was also thinking that these code lines in app(_dev).php are not at all documented, and it might make sense to comment them (especially if they can or should be removed under certain circumstances). WDYT ?
nicolas-grekas commentedon Dec 5, 2017
Alternatively, can you try to turn container.dumper.inline_class_loader to false? and then to remove it?
(while reverting the previous change)
weaverryan commentedon Dec 5, 2017
So are those 2 settings (loadClassCache and inline_class_loader) incompat? Is there something that needs fixing or not?
nicolas-grekas commentedon Dec 5, 2017
There are incompatible, but that should be already handled:
https://github.com/symfony/symfony/blob/3.4/src/Symfony/Component/HttpKernel/Kernel.php#L842
dunno what's missing - maybe a PHP version check also, adding
\PHP_VERSION_ID >= 70000
to the existing check.@gnutix some more debugging hints would help (also trying this additional check please)
gnutix commentedon Dec 5, 2017
Setting
container.dumper.inline_class_loader
tofalse
resolves the issue. Same when using:along with
container.dumper.inline_class_loader
set totrue
.bug #25363 [HttpKernel] Disable inlining on PHP 5 (nicolas-grekas)
gnutix commentedon Dec 7, 2017
Thanks Nicolas for the fix. So the idea is that the AppKernel.php codes enables it, and behind the scene it's disabled for PHP < 7. Guess that's alright for such a "not-well-know" optimization parameter, but still I find it a bit strange. We do have PHP 7 conditions in app.php/app_dev.php so it's explicit. Why not in AppKernel too ?
seblegall commentedon Dec 14, 2017
Thx for the fix @nicolas-grekas. We just crashed the all Meetic website due to this error. :-) I guess we will wait for the 4.4.2 to be release before upgrading to sf 3.4.
sroze commentedon Dec 14, 2017
@seblegall You mean 3.4.2, right? 😄
seblegall commentedon Dec 14, 2017
Yeah, of course. ;-)
behradkhodayar commentedon Jan 2, 2018
Right after installing a
SF 3.4.1
it worked fine, but only after a server restart everything crashed getting the same error!mehdimabrouk commentedon Nov 1, 2018
You can upgrade to symfony3.4.2 and resolve the problem
bennet-enqos commentedon Feb 8, 2020
I just removed the files in var/cache/prod and var/cache/dev inside the project folder. It worked for me