Skip to content
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

After Symfony Kernel reboot - Doctrine EventManager keep old Container #24

Open
ewgRa opened this issue Nov 16, 2016 · 1 comment
Open

Comments

@ewgRa
Copy link

ewgRa commented Nov 16, 2016

What are you trying to achieve?

I have case, when my service have some state, like MemoryStorage collect some data and I want to test what it collects. This MemoryStorage filled by some listeners, subscribed to Doctrine events.

What do you get instead?

My MemoryStorage empty.

Here is reproduce test https://github.com/ewgRa/symfony-standard/blob/codeception-bug-with-container/tests/functional/ContainerCest.php .

tryToTest failed, and tryToTestProof show the reason why it fail.
Problem that doctrine.orm.entity_manager is persistent service and it have EventManager, that actually ContainerAwareEventManager, that store container.
When Symfony module reboot kernel, it create new Container, but since doctrine is persistent, EventManager continue keep old container.
As a result Doctrine events work with its own container, while $I->grabService(...) work with another container.

Reproduce:
git clone [email protected]:ewgRa/symfony-standard.git
cd symfony-standard/
git checkout codeception-bug-with-container
composer install
vendor/bin/codecept run

So, is it feature? Or bug? Looks like 100% bug. Possible solution is update EventManager container also on kernel reboot. Or another solution - unpersist doctrine.

At least this must be mentioned somehow in documentation. Also some "I make service persistent, and it not works" issues can be related to this.

@ewgRa ewgRa changed the title After Symfony Kernel reboot Doctrine EntityManager-EventManager keep old Container After Symfony Kernel reboot - Doctrine EventManager keep old Container Nov 16, 2016
@toby-griffiths
Copy link

We've experienced this issue as well, with event doctrine event listeners being persisted within the entity manager, whilst other services access the newly created container services (rather than the some ones in the EntityManager::$uow::$listenersInvoker::$eventManager::$listeners).

@Naktibalda Naktibalda transferred this issue from Codeception/Codeception Jan 10, 2021
@TavoNiievez TavoNiievez transferred this issue from Codeception/module-doctrine2 Feb 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants