symfony: Upgrade to 5.2.4. gives Undefined index: _service_doctrine.orm.default_listeners.attach_entity_listeners
Symfony version(s) affected: 5.2.4
Description Undefined index: _service_doctrine.orm.default_listeners.attach_entity_listeners
How to reproduce Downgrading to 5.2.3. the error disappears
Additional context
[2021-03-04T20:30:49.646533+01:00] request.CRITICAL: Exception thrown when handling an exception (ErrorException: Notice: Undefined index: _service_doctrine.orm.default_listeners.attach_entity_listeners at /app/vendor/symfony/doctrine-bridge/ContainerAwareEventManager.php line 64) {"exception":"[object] (ErrorException(code: 0): Notice: Undefined index: _service_doctrine.orm.default_listeners.attach_entity_listeners at /app/vendor/symfony/doctrine-bridge/ContainerAwareEventManager.php:64)"} []
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 1
- Comments: 24 (8 by maintainers)
Commits related to this issue
- bug #40425 [DoctrineBridge] Fix eventListener initialization when eventSubscriber constructor dispatch an event (jderusse) This PR was merged into the 4.4 branch. Discussion ---------- [DoctrineBri... — committed to symfony/symfony by fabpot 3 years ago
- bug #12447 Fix build for CoreBundle and ApiBundle packages (pamil) This PR was merged into the 1.9 branch. Discussion ---------- See https://github.com/symfony/symfony/issues/40365, the fix for ^5.... — committed to Sylius/Sylius by pamil 3 years ago
We regularly merge lower branches up into all still maintained branches. So this will also land in 5.2.
The same happens on 4.4.20 as well.
could you please provide a reproducer ?
@jderusse Here is a reproducer:
https://github.com/michanismus/eventsmanager-reproducer
Error appears when an listener added by subscriber triggers an
loadClassMetadata
. Then there is a nested call for the event.https://github.com/symfony/doctrine-bridge/blob/9e2c53f3e8f8a6ccecd80de5c2c8b71beeca7fc8/ContainerAwareEventManager.php#L180
To fix that the line 180 has to be replaced with:
Edit:
Request the TestController route
/
.@jderusse
Here is the bugfix, sorry, I do not have the time to create a PR. Replace the function
initializeSubscribers
. You simple merged uninitialized listeners with initialized without a check.