Git Product home page Git Product logo

Comments (20)

verschoof avatar verschoof commented on August 28, 2024 1

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.

schmittjoh avatar schmittjoh commented on August 28, 2024

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.

fwiethof avatar fwiethof commented on August 28, 2024

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.

stof avatar stof commented on August 28, 2024

It looks like an issue during the cache warming, referencing the wrong cache folder

from jmsdiextrabundle.

schmittjoh avatar schmittjoh commented on August 28, 2024

Could you try to do a cache:warmup after you have manually removed the cache directory (rm -Rf app/cache/*)?

from jmsdiextrabundle.

fwiethof avatar fwiethof commented on August 28, 2024

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.

i3or1s avatar i3or1s commented on August 28, 2024

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.

stof avatar stof commented on August 28, 2024

@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.

i3or1s avatar i3or1s commented on August 28, 2024

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.

schmittjoh avatar schmittjoh commented on August 28, 2024

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.

predakanga avatar predakanga commented on August 28, 2024

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.

jmcclell avatar jmcclell commented on August 28, 2024

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.

fwiethof avatar fwiethof commented on August 28, 2024

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.

bertrandom avatar bertrandom commented on August 28, 2024

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.

MasterB avatar MasterB commented on August 28, 2024

same issue. only rm -rf app/cache/* helps

from jmsdiextrabundle.

schmittjoh avatar schmittjoh commented on August 28, 2024

I have committed a work-around for this problem. Could you try and let me know whether it works for you?

from jmsdiextrabundle.

predakanga avatar predakanga commented on August 28, 2024

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.

bertrandom avatar bertrandom commented on August 28, 2024

Works for me, thanks!

from jmsdiextrabundle.

schmittjoh avatar schmittjoh commented on August 28, 2024

Ok, great.

Closing this then.

from jmsdiextrabundle.

fwiethof avatar fwiethof commented on August 28, 2024

Hello Johannes,

Also works for me. Thanks a lot!

Best regards,
Florian

from jmsdiextrabundle.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.