Skip to content

[HttpKernel] [EventDispatcher] TraceableEventDispatcher kills event priorities #8405

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

Closed
wants to merge 2 commits into from

Conversation

subsven
Copy link
Contributor

@subsven subsven commented Jul 2, 2013

Q A
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets -
License MIT
Doc PR -

Fix a bug where the TraceableEventDispatcher sets all event priorities to 0 when wrapping the events.

I stumpled across this problem when running multiple consecutive BrowserKit requests from a single functional test case.
Sometimes the ContextListener's kernel.response event handler was called after the TestSessionListener's handler, which leads to a started session after finishing the request.
This causes a "Cannot set session ID after the session has started." error on the subsequent request.

I fixed this by introducing a new return value to the EventDispatcher's removeListener method: it now returns the priority of the Event removed so it's easy for the TraceableEventDispatcher to add a wrapped event with the same priority.

…s to

0 when wrapping the events.

I stumpled across this problem when running multiple consecutive BrowserKit requests from a single functional test case.
Sometimes the ContextListener's kernel.response event handler was called after the TestSessionListener's handler, which leads to a started session after finishing the request.
This causes a "Cannot set session ID after the session has started." error on the subsequent request.
@@ -66,6 +66,8 @@ public function addSubscriber(EventSubscriberInterface $subscriber);
*
* @param string|array $eventName The event(s) to remove a listener from
* @param callable $listener The listener to remove
*
* @return integer The listener's priority value
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a BC break

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, point taken. I've added a new method getListenerPriority() to the EventDispatcherInterface.

…ity() method on the EventDispatcherInterface
*
* @return integer|null The listener's priority value, null if the listener wasn't found
*/
public function getListenerPriority($eventName, $listener);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

adding a new method in an existing interface is, unfortunately, also a BC break :(

@subsven
Copy link
Contributor Author

subsven commented Jul 3, 2013

Hm, but how can I fix this bug without BC breaks?

A workaround would be to disable the TraceableEventDispatcher for the "test" environment, but then app/config/config_test.* could not import app/config/config_dev.*. And the order of events in the env-environment would still be different than in the prod-environment, which is really bad for debugging.

@subsven
Copy link
Contributor Author

subsven commented Jul 5, 2013

Since this is obviously not the right way to solve this problem I closed this pull request for now and opened a issue (#8426).

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

Successfully merging this pull request may close these issues.

3 participants