Comments (20)
I think I have the same problem as the topic starter..
php app/console cache:clear --env=prod
Clearing the cache for the prod environment with debug false
PHP Fatal error: Cannot redeclare class EnhancedProxy_ed2f3cb92db5d961490e60a593d20b156b460b0d\__CG__\MV\CaravanBundle\Controller\AdminLogController in /home/lepapill/domains/domain.com/app/cache/pro_/jms_diextra/proxies/MV-CaravanBundle-Controller-AdminLogController.php on line 37
composer.json
"jms/di-extra-bundle": "1.1.*"
I did try to clear it manually and run the application but that failed.. any ideas?
from jmsdiextrabundle.
Does this happen when you run cache:clear, or when you run cache:warmup? Could you also try manually deleting the cache directory, and just running cache:warmup?
from jmsdiextrabundle.
When I do a cache:clear, it always happens (also verified by grepping for "dev_new" in the cache directory right after cache:clear).
I did not try cache:warmup. Do you want me to do that?
When I delete the cache directory it behaves just like when I do cache:clear, however, sometimes it does not happen then. When I then gradually readd annotations that I have commented out before (without clearing the cache, just reloading the page in dev environment) the problem eventually occurs (and does not go away until I remove one or more annotations). However, I was not able to consistently reproduce it.
May be its related to the number of annotations, since I did not have the problem at all in the beginning yesterday (I just started to implement security in my application). After I added more and more annotations, it got worse.
-----Ursprüngliche Nachricht-----
Von: Johannes [mailto:[email protected]]
Gesendet: Freitag, 1. Juni 2012 02:50
An: Florian Wiethoff
Betreff: Re: [JMSDiExtraBundle] Bug in CacheWarmer? (#23)
Does this happen when you run cache:clear, or when you run cache:warmup? Could you also try manually deleting the cache directory, and just running cache:warmup?
Reply to this email directly or view it on GitHub:
#23 (comment)
from jmsdiextrabundle.
It looks like an issue during the cache warming, referencing the wrong cache folder
from jmsdiextrabundle.
Could you try to do a cache:warmup after you have manually removed the cache directory (rm -Rf app/cache/*
)?
from jmsdiextrabundle.
I did this:
fwiethof@hydra:~/dev/braintower/tools/symfony$ php bin/vendors install
You are using the latest composer version.
Installing dependencies from lock file
- Installing jms/di-extra-bundle (dev-master)
Cloning bd953ff196ecbb36080eff0c93fb3d735726d26b
Generating autoload files
Installing assets using the hard copy option
Installing assets for Symfony\Bundle\FrameworkBundle into /home/fwiethof/dev/braintower/tools/symfony/web/bundles/framework
Installing assets for Mopa\Bundle\BootstrapBundle into /home/fwiethof/dev/braintower/tools/symfony/web/bundles/mopabootstrap
Installing assets for Braintower\UIBundle into /home/fwiethof/dev/braintower/tools/symfony/web/bundles/braintowerui
Installing assets for Symfony\Bundle\WebProfilerBundle into /home/fwiethof/dev/braintower/tools/symfony/web/bundles/webprofiler
Installing assets for Elao\WebProfilerExtraBundle into /home/fwiethof/dev/braintower/tools/symfony/web/bundles/webprofilerextra
Clearing the cache for the dev environment with debug true
fwiethof@hydra:~/dev/braintower/tools/symfony$ rm -Rf app/cache/*
fwiethof@hydra:~/dev/braintower/tools/symfony$ php app/console cache:warmup
Warming up the cache for the dev environment with debug true
When accessing the URL I had problems with last time, the problem does not occur anymore.
However, when I do:
fwiethof@hydra:~/dev/braintower/tools/symfony$ php app/console cache:clear
or even
fwiethof@hydra:~/dev/braintower/tools/symfony$ rm -Rf app/cache/*
fwiethof@hydra:~/dev/braintower/tools/symfony$ php app/console cache:clear
it always happens.
from jmsdiextrabundle.
Hi i am getting the same thing.
When i do cache:warmup it is all ok, but if my cache is empty and i do cache:clear i get the error.
"Fatal error: Cannot redeclare class appdevUrlGenerator in .../app/cache/dev_new/appdevUrlGenerator.php on line 62"
Entire problem emerged because i was making a warmup class for a MenuBundle that i am trying to build.
In this warmup class i am using routing service which reports this fatal error.
It is a strange error, i guess it has something to do with shuffling files (dev, dev_new)?
from jmsdiextrabundle.
@i3or1s if your warmer need to access the router, you need to make it run after the routing cache warmer (there is a priority in cache warmers for this) to ensure that the routing is already warmed up.
from jmsdiextrabundle.
Thank you for the information this did the trick. By the way this is really ql i did not know that there is a priority attribute.
from jmsdiextrabundle.
I looked into this. The problem here is that the cache is built in a different directory, thus require_once does not prevent the same class from being included twice.
Currently, I do not see any feasible fix except simply using the good way to clear your cache rm -rf app/cache/*
or removing the cache warmer.
Anyone else with better ideas?
from jmsdiextrabundle.
In lieu of a better solution, would it be possible to throw an exception in ControllerCacheWarmer::warmUp if the cache dir ends in _new (possibly check the current environment vs that for safety)?
It's quite an obtuse error to trace back - for me, it presented itself by pages only half-rendering in production mode; no errors were given at all.
from jmsdiextrabundle.
So is the answer here to simply not use cache:clear? That seems like a rather unsatisfying response, not that I don't sympathize with the difficulty in solving the issue.
It's odd that it only happens every other cache:clear. Is someone able to articulate why that is, because I'm not seeing why it wouldn't happen on every clear.
from jmsdiextrabundle.
Hello,
By the way, I agree with that.
Especially because it makes development very inconvenient since when I change a source file, the problem is also triggered in the dev environment. This means, that I have to delete the cache after each change to a file.
So having that fixed would be really great. In the meantime, I’ll stick to the old version.
Best regards,
Florian
from jmsdiextrabundle.
I added a pass that changes the file to the original require_once used, thus avoiding the redeclaration error. I had to use a lookup table but it seems pretty fast, let me know what you think.
from jmsdiextrabundle.
same issue. only rm -rf app/cache/* helps
from jmsdiextrabundle.
I have committed a work-around for this problem. Could you try and let me know whether it works for you?
from jmsdiextrabundle.
Your work-around works for me - cache cleared on both dev and prod environments without causing any tests to fail, and without producing any files which reference _new
Thanks, @schmittjoh
from jmsdiextrabundle.
Works for me, thanks!
from jmsdiextrabundle.
Ok, great.
Closing this then.
from jmsdiextrabundle.
Hello Johannes,
Also works for me. Thanks a lot!
Best regards,
Florian
from jmsdiextrabundle.
Related Issues (20)
- Symfony autowiring broken by JMSDiExtraBundle HOT 8
- Container cache miss occurs on tests since Symfony 3.2.
- Unable to reset entity manager with doctrine_integration enabled HOT 1
- Getting error after updating to #55c3f875f08a333848284cdbc1fd3e0cea4e6776 HOT 22
- addClassesToCompile() is deprecated since Symfony version 3.3, to be removed in 4.0 HOT 4
- Parent definition does not exist HOT 4
- Implement the new !tagged functionality
- Translation WebInterface: Unable to find template "@JMSTranslation/translate/index.html.twig" HOT 2
- Symfony 3.4 HOT 3
- Doctrine orm service must be true by default HOT 2
- Annotations not working when using PHP through FastCGI HOT 3
- Compatible with Symfony4 require HOT 2
- Unrecognized options HOT 1
- Cache clear, cannot declare class HOT 2
- IOException with Paratest HOT 3
- Symfony 4 support HOT 5
- Call to a member function has() on null HOT 6
- Symfony 3.4 setScope Call to undefined method HOT 2
- Support for "jms/metadata": "^2.0"
- PHP 8 support HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jmsdiextrabundle.