Open swis opened 11 years ago
@tkleinhakisa More code means more chances of bugs. More code also means longer execution times (generally speaking). I do not wish to have 3 bundles just to add an @Secure to my page. Sadly, this forces me to use these 3 bundles. I guess the only way to fix this is to write a custom bundle.
Anyway that's not the point here ...
@schmittjoh From what i've learned so far digging into this issue, one solution would be to have the proxy classes autoloaded so the problematic "require_once" statements could be removed. Any help on this would be greatly appreciated, some hints about where to start, or just a feedback on "do-ability"
Maybe as first step we should create a clean standard-edition fork with a minimal setup to reproduce the issue
@tkleinhakisa I did not drop the bundles; instead I've added a post-install command which removes the unit-tests from that bundle, so now everything works smooth.
However, just so you know, for me Production has same issue as Dev:
l(esoh@cristi-vm)-(02:22 PM Mon Nov 18)-(/var/www/)-(13 files, 1.1Mb) | {feature/i18n} $
./app/console cache:clear --env=prod Clearing the cache for the prod environment with debug false PHP Fatal error: Cannot redeclare class EnhancedProxy73b88e6bf5989f9e4785cea753cad509a15376f1CG\JMS\SecurityExtraBundle\Tests\Functional\TestBundle\Controller\PostController in /var/www/app/cache/pro/jms_diextra/lookup_method_classes/JMS-SecurityExtraBundle-Tests-Functional-TestBundle-Controller-PostController.php on line 11 l(esoh@cristi-vm)-(02:22 PM Mon Nov 18)-(/var/www/)-(13 files, 1.1Mb) | {feature/i18n} $
I think the best solution would be what I've written in a comment above, https://github.com/schmittjoh/JMSDiExtraBundle/issues/96#issuecomment-21028440
I think that adding a command to invoke manualy is not an option ... what about the case when you get the error after refreshing a page in the browser ? should i run the additionnal command every time i make a change in my controller ? maybe i missed something ...
That's my problem exactly, I get this error after a page refresh.
Ah, that's interesting. Then, we are talking about different errors here.
Maybe we need to implement a similar strategy as the DoctrineBundle: https://github.com/doctrine/DoctrineBundle/blob/master/DoctrineBundle.php#L101
The 2 errors leeds to the same exception message: cannot redeclare class etc ... see https://github.com/schmittjoh/JMSDiExtraBundle/issues/96#issuecomment-24142354
They append in different places but the error is caused by the "require" statements ... so having autoloading for the proxies would solve both cases, so yes a strategy like doctrine would solve the problem i think
Could you check whether the workaround in #131 fixes these issues for you? If so, I'll merge that.
@schmittjoh see https://github.com/schmittjoh/JMSDiExtraBundle/issues/96#issuecomment-28063266
not fixing the issue on page refresh
I had this problem today while installing JMSTranslationBundle UI... was going crazzy because I really needed this feature for a prod project. When deleting the cache folder or executing cache:clear
, was getting the error. In fact, I was keeping a copy of one of my controller with the sufix "2Controller". When I deleted it, everything were working fine !
The issue seems to have been fixed in a way or another ... i didn't get that error for a longtime now in dev ... should make some further test to be sure ...
Still getting this issue with symfony 2.4.6, jms/di-extra-bundle 1.4.0
I have the same (?) error using jms/di-extra-bundle dev-master in combination with Symfony 2.5.2 and "coresphere/console-bundle" - I am trying to run the clear cache command from the browser (don't ask why ;-)).
I have the same error with 2.3.18 I am unable to reproduce what I have added to my code. If I run cache:clear twice, I get the error ... If I run cache:clear after cache:warmup ... it works fine (which is expected) ... I am using: "jms/security-extra-bundle": "~1.5",
Any thoughts?
I had the same problem. What worked for us was removing the automatic warmup from the clear command: app/console cache:clear --no-warmup --no-optional-warmers
The warmup can be called as a separate command if needed.
Same issue for us: we have Cannot redeclare class EnhancedProxy73b88e6bf5989f9e4785cea753cad509a15376f1CG\JMS\SecurityExtraBundle\Tests\Functional\TestBundle\Controller\PostController in /mnt/www/nextop/releases/20150422071136/app/cache/pro/jms_diextra/lookup_method_classes/JMS-SecurityExtraBundle-Tests-Functional-TestBundle-Controller-PostController.php on line 11 [2015-04-22 09:26:18] php.EMERGENCY: Fatal Compile Error: Cannot redeclare class EnhancedProxy73b88e6bf5989f9e4785cea753cad509a15376f1CG\JMS\SecurityExtraBundle\Tests\Functional\TestBundle\Controller\PostController {"type":1,"file":"/mnt/www/nextop/releases/20150422071136/app/cache/pro/jms_diextra/lookup_method_classes/JMS-SecurityExtraBundle-Tests-Functional-TestBundle-Controller-PostController.php","line":11,"level":6143,"stack":[]}
2015/04/22 07:08:28 [error] 7766#0: *91117 FastCGI sent in stderr: "PHP message: PHP Warning: require_once(/mnt/www/nextop/releases/20150421142932/app/cache/prod/jms_diextra/doctrine/EntityManager_55365f87a155a.php): failed to open stream: No such file or directory in /mnt/www/nextop/releases/20150421142932/app/cache/prod/appProdProjectContainer.php on line 1288 PHP message: PHP Fatal error: require_once(): Failed opening required '/mnt/www/nextop/releases/20150421142932/app/cache/prod/jms_diextra/doctrine/EntityManager_55365f87a155a.php' (include_path='/mnt/www/nextop/releases/20150421142932/vendor/phpunit/php-text-template:/mnt/www/nextop/releases/20150421142932/vendor/phpunit/php-timer:.:/usr/share/php:/usr/share/pear') in /mnt/www/nextop/releases/20150421142932/app/cache/prod/appProdProjectContainer.php on line 1288" while reading response header from upstream, client: 172.31.16.102, server: www.xxx.it, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "www.xxx.it"
We had the same issue, and for us the solution from @Metabor also worked.
We have the same issue when upgrading from symfony 2.3 to 2.8
I just added some ACL stuff to my project and now, when clearing the cache with
immediately I got the following error:
I already tried different versions of Symfony and DiExtraBundle (and different combinations), but the error remains even when I downgrade Symfony to 2.1. I don't know, but I suppose, this is somehow related to #95 - especially because of this CacheWarmer issue in the Stack. But I'm pretty sure, to not compile any Controller manually. Here's my current composer.json:
I'm looking for a workaround, since clearing the cache manually by removing the files is not appropriate in my case (especially for the CI stuff).
It may be of note that I'm using
@SecureParam
as well as@Secure
annotations (the error occurs even if I use only one of them in the BackendController).