symfony/symfony — pull request #8405 by subsven (2013-07-02 13:02:28+00:00)
Title: [HttpKernel] [EventDispatcher] TraceableEventDispatcher kills event priorities

| 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.