Skip to content

Commit 419bcf6

Browse files
committed
bug #20871 [HttpKernel] Give higher priority to adding request formats (akeeman)
This PR was submitted for the master branch but it was merged into the 2.7 branch instead (closes #20871). Discussion ---------- [HttpKernel] Give higher priority to adding request formats | Q | A | ------------- | --- | Branch? | 3.2 | Bug fix? | yes | New feature? | yes | BC breaks? | yes (unlikely to break projects*) | Deprecations? | no | Tests pass? | yes | Fixed tickets | none | License | MIT | Doc PR | not documented \* Only applies to the unlikely case where formats are used before this event is loaded key. Users must have specified custom formats, and actually using them should then break their application. I think that's an unlikely case. ## Problem It's possible to extend the formats known by the `Request` using a piece of config: ```yaml framework: request: formats: json: 'application/merge-patch+json' ``` Using this in a `kernel.request` event is currently not possible, as it loads after any custom events. ## Offered solution Increasing the priority of the AddRequestFormatsListener listener resolves this problem. This change only impacts projects that use the `framework.request.formats` configuration key, as the listener is not loaded if it isn't defined. Commits ------- 9edb457 [HttpKernel] Give higher priority to adding request formats
2 parents 1dfb108 + 9edb457 commit 419bcf6

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/Symfony/Component/HttpKernel/EventListener/AddRequestFormatsListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,6 @@ public function onKernelRequest(GetResponseEvent $event)
5252
*/
5353
public static function getSubscribedEvents()
5454
{
55-
return array(KernelEvents::REQUEST => 'onKernelRequest');
55+
return array(KernelEvents::REQUEST => array('onKernelRequest', 1));
5656
}
5757
}

src/Symfony/Component/HttpKernel/Tests/EventListener/AddRequestFormatsListenerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function testIsAnEventSubscriber()
4545
public function testRegisteredEvent()
4646
{
4747
$this->assertEquals(
48-
array(KernelEvents::REQUEST => 'onKernelRequest'),
48+
array(KernelEvents::REQUEST => array('onKernelRequest', 1)),
4949
AddRequestFormatsListener::getSubscribedEvents()
5050
);
5151
}

0 commit comments

Comments
 (0)