JMSDiExtraBundle icon indicating copy to clipboard operation
JMSDiExtraBundle copied to clipboard

[2.2] Random 500 Redeclare Symfony\Bundle\FrameworkBundle\Controller\Controller

Open emgiezet opened this issue 12 years ago • 7 comments
trafficstars

Hi!

I got this 500 randomly once or twice per 10 requests.

FatalErrorException: Compile Error: Cannot redeclare class Symfony\Bundle\FrameworkBundle\Controller\Controller in /home/mgz/workspace/Interim/cms/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Controller/Controller.php line 254

Here is the trace:

in /home/mgz/workspace/Interim/cms/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Controller/Controller.php line 254
at ErrorHandler->handleFatal() in /home/mgz/workspace/Interim/cms/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Debug/ErrorHandler.php line 0
at ControllerInjectorsWarmer->findControllerClasses() in /home/mgz/workspace/Interim/cms/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/HttpKernel/ControllerInjectorsWarmer.php line 35
at ControllerInjectorsWarmer->warmUp() in /home/mgz/workspace/Interim/cms/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/CacheWarmer/CacheWarmerAggregate.php line 47
at CacheWarmerAggregate->warmUp() in /home/mgz/workspace/Interim/cms/app/bootstrap.php.cache line 601
at Kernel->initializeContainer() in /home/mgz/workspace/Interim/cms/app/bootstrap.php.cache line 378
at Kernel->boot() in /home/mgz/workspace/Interim/cms/app/bootstrap.php.cache line 409
at Kernel->handle() in /home/mgz/workspace/Interim/cms/web/app_dev.php line 18
at ??{main}() in /home/mgz/workspace/Interim/cms/web/app_dev.php line 0

Project is basic configured sf 2.2 with sonata & fosuserbundle with APC and Memcached. It happens on dev env.

emgiezet avatar Mar 11 '13 14:03 emgiezet

Are you using the compiled class file? If so, can you try whether you get the error when you disable it?

Did this error occur on Symfony 2.1?

schmittjoh avatar Mar 11 '13 14:03 schmittjoh

@schmittjoh FYI, sonata removed their controllers from the compiled class file in their 2.1 branch recently but it has not yet been merged into master for 2.2. But DIExtraBundle should not break when it is used IMO.

stof avatar Mar 11 '13 15:03 stof

This happens when I'm using clean symfony generated controllers o FOSUserBundle login/register actions. It's not connected with sonata.

emgiezet avatar Mar 11 '13 15:03 emgiezet

@emgiezet, you'll need to give some more precise debugging details like the exact versions, whether or not you use the compiled class cache, whether or not this happened on Symfony 2.1 (if you upgraded).

@stof, I'm all for not breaking things if this is possible. In order to assess this, we first need to find the cause though, and by cause I do not mean the class in which it happens, but why it happens now and has not happened before.

schmittjoh avatar Mar 11 '13 15:03 schmittjoh

the reason is that the cache warmer is requiring all controllers, which break if one of them was defined in the bootstrap file

stof avatar Mar 11 '13 16:03 stof

I'm aware that compiled controllers are not supported by this bundle, and if @emgiezet can confirm that this is indeed causing the issue for him, then we would need to see when this class was added to the compiled files, and remove it again.

This is not only necessary for the cache warmer to work, but also required to keep annotation parsing at an acceptable performance level. Then, we could also look into providing a better error message for these cases, but at this point, I do not know what we could except parsing all files before including them, or removing the cache warmer.

schmittjoh avatar Mar 11 '13 17:03 schmittjoh

@schmittjoh how about checking if the controller class exists already before requiring the file? I'm not sure why the bundle requires them instead of relying on autoloading anyway? Obviously this would break if people don't follow PSR-0, but I don't know if that's really an issue in sf2 projects.

Seldaek avatar May 03 '13 09:05 Seldaek