-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[EventDispatcher] Try first if the event is Stopped #18426
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
Conversation
Does it make sense to dispatch stopped event? Raising exception here seems more appropriate. |
I don't think so, because it will make userland code harder to write. |
@lyrixx I think such case should add a log message in the traceable event dispatcher, as it could also be a mistake in the userland code (people not knowing that stopping the the propagation of the first event will impact the next event because they reused the same event object) |
@stof Good idea. I added it. |
👍 |
How does error reporting make harder to write? |
👍 |
there is not error IMHO. see this for instance: https://github.com/symfony/symfony/pull/11882/files#diff-6d1e8dc0d2c0e7c4ab206d0efbb71516R161 |
Thank you @lyrixx. |
This PR was merged into the 2.3 branch. Discussion ---------- [EventDispatcher] Try first if the event is Stopped | Q | A | ------------- | --- | Branch? | 2.3 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - If you trigger 2 events with the same instance of Event and if a listener in the first dispatch stop the propagation, then the very first listener of the second dispatch is called. It should not IMHO. Commits ------- a30e166 [EventDispatcher] Try first if the event is Stopped
If you trigger 2 events with the same instance of Event and if a listener in the first dispatch stop the propagation, then the very first listener of the second dispatch is called. It should not IMHO.