File tree Expand file tree Collapse file tree 2 files changed +9
-1
lines changed
src/Symfony/Component/HttpFoundation Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -1276,7 +1276,10 @@ public function getMethod()
1276
1276
if ($ method = $ this ->headers ->get ('X-HTTP-METHOD-OVERRIDE ' )) {
1277
1277
$ this ->method = strtoupper ($ method );
1278
1278
} elseif (self ::$ httpMethodParameterOverride ) {
1279
- $ this ->method = strtoupper ($ this ->request ->get ('_method ' , $ this ->query ->get ('_method ' , 'POST ' )));
1279
+ $ method = $ this ->request ->get ('_method ' , $ this ->query ->get ('_method ' , 'POST ' ));
1280
+ if (\is_string ($ method )) {
1281
+ $ this ->method = strtoupper ($ method );
1282
+ }
1280
1283
}
1281
1284
}
1282
1285
}
Original file line number Diff line number Diff line change @@ -816,6 +816,11 @@ public function testGetSetMethod()
816
816
$ request ->setMethod ('POST ' );
817
817
$ request ->headers ->set ('X-HTTP-METHOD-OVERRIDE ' , 'delete ' );
818
818
$ this ->assertEquals ('DELETE ' , $ request ->getMethod (), '->getMethod() returns the method from X-HTTP-Method-Override if defined and POST ' );
819
+
820
+ $ request = new Request ();
821
+ $ request ->setMethod ('POST ' );
822
+ $ request ->query ->set ('_method ' , array ('delete ' , 'patch ' ));
823
+ $ this ->assertSame ('POST ' , $ request ->getMethod (), '->getMethod() returns the request method if invalid type is defined in query ' );
819
824
}
820
825
821
826
/**
You can’t perform that action at this time.
0 commit comments