-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[HttpKernel] Nested events in TraceableEventDispatcher #9710
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
Comments
… the TraceableEventDispatcher
which version are you using ? I think we already fixed the issue about the dispatcher instance in Symfony 2.4 |
The tests in my fork are against the current master - should I rebase them onto 2.4? |
Either way though, the issue should still be present in 2.4. It's happening because TraceableEventDispatcher is using |
Sorry for the comment spam - the specific line where the issue pops up is: |
oh, you mean you are using the same |
Yeah, you have to manually ensure that propagation has not stopped, or be sure to return immediately if it has. Do you think I should go ahead and submit a PR? Also, should I add a test in the |
@evillemez what I mean is that stopping the propagation for 1 event will stop it for the other dispatching as well, which may not be what you expect. However, fixing the issue should be easy IMO: you just need to generate a random id in the |
@stof Ah, right, yeah that is the behavior I was expecting, though. I think your solution is more straight forward than mine, I was going implement some sort of reference counting based on the id. A random number would probably be fine though and less work. I'll put together a PR when I get to work in the morning. |
…ested events (evillemez) This PR was merged into the 2.3 branch. Discussion ---------- allow TraceableEventDispatcher to reuse event instance in nested events | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #9710, #9727 | License | MIT Commits ------- 454ce16 allow TraceableEventDispatcher to reuse event instance in nested events
The
HttpKernel\Debug\TraceableEventDispatcher
cannot handle nested dispatches of the same event instance. This behavior differs from the default implementation inEventDispatcher\EventDispatcher
, which does not care what event is being dispatched.I have some tests demonstrating the issue in my own fork here:
https://github.com/evillemez/symfony/blob/events/src/Symfony/Component/HttpKernel/Tests/Debug/TraceableEventDispatcherTest.php#L151
A related issue I discovered is that, when handling an event dispatched by
TraceableEventDispatcher
calls to$e->getDispatcher()
return the wrappedEventDispatcher
instance, not the wrappingTraceableEventDispatcher
instance. So, if an event is being re-dispatched under a new name, those calls are not being traced. I'm not sure if that should be a separate issue, or not.I'll start working on a PR to make the behaviors match, but would like some feedback.
The text was updated successfully, but these errors were encountered: