8000 [Cache] Cannot redeclare class Acme in /path/to/Acme.php · Issue #25484 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Cache] Cannot redeclare class Acme in /path/to/Acme.php #25484

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
althaus opened this issue Dec 13, 2017 · 10 comments
Closed

[Cache] Cannot redeclare class Acme in /path/to/Acme.php #25484

althaus opened this issue Dec 13, 2017 · 10 comments

Comments

@althaus
Copy link
Contributor
althaus commented Dec 13, 2017
Q A
Bug report? yes
Feature request? no
BC Break report? no
RFC? no
Symfony version 3.4.1
PHP version 5.6.x

After upgrading to Symfony 3.4.1 I'm encountering strange caching issues.

In dev I get "Cannot redeclare class EventSubscriberInterface" with a fresh cache after the first successfull page load. In that case the first broken call is the web profiler on that exact page. Reloading the page directly runs into the FatalErrorException. I got it twice directly after executing a doctine:migration:foo command and once after switching branches or something like that.

In prod I get (on my dev and another totally different machine) a "PHP Fatal error: Cannot redeclare class appProdProjectContainer in /var/www/conti.ido.software/git/devel/var/cache/prod/appProdProjectContainer.php on line 7519" on warming up the cache.

In dev I could fix it by randomly removing cache, clearing cache and writing dump("foo") into the EventSubscriberInterface file in no particular order. I found #21520 which sounds related.

It's driving me nuts.

@javiereguiluz
Copy link
Member

In the Symfony Demo repository we're also getting reports about similar issues: "Cannot declare class XXX because the name is already in use": symfony/demo#411 (comment)

@althaus
Copy link
Contributor Author
althaus commented Dec 14, 2017

I got it sorted out once by removing the boostrap.cache file. I have to check if this is the cure, if it happens again.

@nicolas-grekas
Copy link
Member

This issue is generally due to this: conflicting inlining strategies between boostrap.cache.php, classes.php and now maybe the inlined "include" in the container. Fortunately, we deprecated the two former, so this will die soon. Just don't use them and done.

@althaus
Copy link
Contributor Author
althaus commented Dec 14, 2017

Just don't use them and done.

How? I just upgrade from 3.3 to 3.4 and did all relevant upgrades from UPGRADE-3.4.md. There's nothing stated about those files?

@althaus
Copy link
Contributor Author
althaus commented Dec 14, 2017

Ok... just killing the bootstrap file isn't the solution. Redoing all caches still falls back to the exception.

btw: I'm currently pinned on PHP 5 and as far as I understand the app*.php files, dropping the bootstrap file is for PHP 7 only.

@nicolas-grekas
Copy link
Member

v3.4.2 will embed a fix for this so that no action will be required anymore. See #25363

@althaus
Copy link
Contributor Author
althaus commented Dec 14, 2017

Okay, thanks!

I'll got for setting container.dumper.inline_class_loader to false and see if the issue vanishes for me, too.

@simonberton
Copy link

Hi, did the container.dumper.inline_class_loader false, fixed the problem?

Using Symfony 3.4.6 and keep getting the "cannot declare class Locale, because the name is already in use"

/Symfony/Component/Intl/Resources/stubs/Locale.php:21

Thanks !!!

@YoannBuzenet
Copy link

Hello, in which file do you add this parameter ?

@TomasVotruba
Copy link
Contributor

Hi, did the container.dumper.inline_class_loader false, fixed the problem?

I can confirm this finally helped me, thank you 👍

Hello, in which file do you add this parameter ?

In your Kernel, e.g. here:

protected function build(ContainerBuilder $containerBuilder): void
{
        $containerBuilder->setParameter('container.dumper.inline_class_loader', false);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants
0