feature #29186 [HttpKernel] Increase priority of AddRequestFormatsListener (thewilkybarkid)

This PR was merged into the 4.3-dev branch.

Discussion
----------

[HttpKernel] Increase priority of AddRequestFormatsListener

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

Currently `AddRequestFormatsListener` has a low priority, so it won't fire before others like `RouterListener` which can create problems (eg when listening for a HTTP exception thrown by the router you don't have access for any custom types).

IMO this map should be in the application rather than set on every request, but the same can be achieved by giving it a high priority. (Can't think of a reason for it to not be first...)

Commits
-------

9bf313660d Increase priority of AddRequestFormatsListener
This commit is contained in:
Fabien Potencier 2019-01-02 11:02:59 +01:00
commit 2ce6a34881
3 changed files with 7 additions and 2 deletions

View File

@ -1,6 +1,11 @@
CHANGELOG
=========
4.3.0
-----
* increased the priority of `Symfony\Component\HttpKernel\EventListener\AddRequestFormatsListener`
4.2.0
-----

View File

@ -45,6 +45,6 @@ class AddRequestFormatsListener implements EventSubscriberInterface
*/
public static function getSubscribedEvents()
{
return array(KernelEvents::REQUEST => array('onKernelRequest', 1));
return array(KernelEvents::REQUEST => array('onKernelRequest', 100));
}
}

View File

@ -46,7 +46,7 @@ class AddRequestFormatsListenerTest extends TestCase
public function testRegisteredEvent()
{
$this->assertEquals(
array(KernelEvents::REQUEST => array('onKernelRequest', 1)),
array(KernelEvents::REQUEST => array('onKernelRequest', 100)),
AddRequestFormatsListener::getSubscribedEvents()
);
}