Skip to content

Commit 2b8edc1

Browse files
committed
Merge pull request #787 from florianv/revert-priority
Revert "Fixed http-method-override"
2 parents cd40682 + cbc256b commit 2b8edc1

File tree

3 files changed

+2
-16
lines changed

3 files changed

+2
-16
lines changed

EventListener/BodyListener.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,6 @@ public function onKernelRequest(GetResponseEvent $event)
109109
}
110110
}
111111
$request->request = new ParameterBag($data);
112-
113-
// Reset the method in the current request to support method-overriding
114-
$request->setMethod($request->getRealMethod());
115112
} else {
116113
throw new BadRequestHttpException('Invalid ' . $format . ' message received');
117114
}

Resources/config/body_listener.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
</service>
3434

3535
<service id="fos_rest.body_listener" class="%fos_rest.body_listener.class%">
36-
<tag name="kernel.event_listener" event="kernel.request" method="onKernelRequest" priority="64" />
36+
<tag name="kernel.event_listener" event="kernel.request" method="onKernelRequest" priority="10" />
3737
<argument type="service" id="fos_rest.decoder_provider" />
3838
<argument>%fos_rest.throw_exception_on_unsupported_content_type%</argument>
3939
</service>

Tests/EventListener/BodyListenerTest.php

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,11 @@ class BodyListenerTest extends \PHPUnit_Framework_TestCase
3232
* @param array $expectedParameters the http parameters of the updated request
3333
* @param string $contentType the request header content type
3434
* @param boolean $throwExceptionOnUnsupportedContentType
35-
* @param string $expectedRequestMethod
3635
*
3736
* @dataProvider testOnKernelRequestDataProvider
3837
*/
39-
public function testOnKernelRequest($decode, Request $request, $method, $expectedParameters, $contentType = null, $throwExceptionOnUnsupportedContentType = false, $expectedRequestMethod = null)
38+
public function testOnKernelRequest($decode, Request $request, $method, $expectedParameters, $contentType = null, $throwExceptionOnUnsupportedContentType = false)
4039
{
41-
if (!$expectedRequestMethod) {
42-
$expectedRequestMethod = $method;
43-
} else {
44-
$request->enableHttpMethodParameterOverride();
45-
}
46-
4740
$decoder = $this->getMockBuilder('FOS\RestBundle\Decoder\DecoderInterface')->disableOriginalConstructor()->getMock();
4841
$decoder->expects($this->any())
4942
->method('decode')
@@ -80,7 +73,6 @@ public function testOnKernelRequest($decode, Request $request, $method, $expecte
8073
$listener->onKernelRequest($event);
8174

8275
$this->assertEquals($request->request->all(), $expectedParameters);
83-
$this->assertEquals($request->getMethod(), $expectedRequestMethod);
8476
}
8577

8678
public static function testOnKernelRequestDataProvider()
@@ -94,9 +86,6 @@ public static function testOnKernelRequestDataProvider()
9486
'POST request with parameters' => array(false, new Request(array(), array('bar'), array(), array(), array(), array(), array('foo')), 'POST', array('bar'), 'application/json'),
9587
'POST request with unallowed format' => array(false, new Request(array(), array(), array(), array(), array(), array(), array('foo')), 'POST', array(), 'application/fooformat'),
9688
'POST request with no Content-Type' => array(true, new Request(array(), array(), array('_format' => 'json'), array(), array(), array(), array('foo')), 'POST', array('foo')),
97-
'POST request with _method parameter and disabled method-override' => array(true, new Request(array(), array(), array('_format' => 'json'), array(), array(), array(), array("_method" => "PUT")), 'POST', array('_method' => 'PUT'), 'application/json'),
98-
// This test is the last one, because you can't disable the http-method-override once it's enabled
99-
'POST request with _method parameter' => array(true, new Request(array(), array(), array('_format' => 'json'), array(), array(), array(), array("_method" => "PUT")), 'POST', array('_method' => 'PUT'), 'application/json', false, "PUT"),
10089
);
10190
}
10291

0 commit comments

Comments
 (0)