Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[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

Merged
merged 1 commit into from
Apr 4, 2016

Conversation

lyrixx
Copy link
Member

@lyrixx lyrixx commented Apr 3, 2016

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.

@unkind
Copy link
Contributor

unkind commented Apr 3, 2016

Does it make sense to dispatch stopped event? Raising exception here seems more appropriate.

@lyrixx lyrixx closed this Apr 3, 2016
@lyrixx lyrixx deleted the event-stopped branch April 3, 2016 22:16
@lyrixx lyrixx restored the event-stopped branch April 3, 2016 22:16
@lyrixx lyrixx reopened this Apr 3, 2016
@lyrixx
Copy link
Member Author

lyrixx commented Apr 4, 2016

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.

@stof
Copy link
Member

stof commented Apr 4, 2016

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

@lyrixx
Copy link
Member Author

lyrixx commented Apr 4, 2016

@stof Good idea. I added it.

@nicolas-grekas
Copy link
Member

👍

@unkind
Copy link
Contributor

unkind commented Apr 4, 2016

I don't think so, because it will make userland code harder to write.

How does error reporting make harder to write?

@javiereguiluz
Copy link
Member

👍

@lyrixx
Copy link
Member Author

lyrixx commented Apr 4, 2016

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

@nicolas-grekas
Copy link
Member

Thank you @lyrixx.

@nicolas-grekas nicolas-grekas merged commit a30e166 into symfony:2.3 Apr 4, 2016
nicolas-grekas added a commit that referenced this pull request Apr 4, 2016
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
@lyrixx lyrixx deleted the event-stopped branch November 10, 2016 09:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants