10000 [Routing] Fix throwing NoConfigurationException instead of 405 · symfony/symfony@742e091 · GitHub
[go: up one dir, main page]

Skip to content

Commit 742e091

Browse files
[Routing] Fix throwing NoConfigurationException instead of 405
1 parent 946eefa commit 742e091

File tree

11 files changed

+25
-10
lines changed

11 files changed

+25
-10
lines changed

src/Symfony/Component/Routing/Matcher/Dumper/PhpMatcherDumper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ private function compileRoutes(RouteCollection $routes, $supportsRedirections)
154154
}
155155

156156
// used to display the Welcome Page in apps that don't define a homepage
157-
$code .= " if ('/' === \$pathinfo) {\n";
157+
$code .= " if ('/' === \$pathinfo && !\$allow) {\n";
158158
$code .= " throw new Symfony\Component\Routing\Exception\NoConfigurationException();\n";
159159
$code .= " }\n";
160160

src/Symfony/Component/Routing/Matcher/UrlMatcher.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public function match($pathinfo)
7676
return $ret;
7777
}
7878

79-
if ('/' === $pathinfo) {
79+
if ('/' === $pathinfo && !$this->allow) {
8080
throw new NoConfigurationException();
8181
}
8282

src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher0.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function match($rawPathinfo)
2828
$canonicalMethod = 'GET';
2929
}
3030

31-
if ('/' === $pathinfo) {
31+
if ('/' === $pathinfo && !$allow) {
3232
throw new Symfony\Component\Routing\Exception\NoConfigurationException();
3333
}
3434

src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher1.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ public function match($rawPathinfo)
309309

310310
}
311311

312-
if ('/' === $pathinfo) {
312+
if ('/' === $pathinfo && !$allow) {
313313
throw new Symfony\Component\Routing\Exception\NoConfigurationException();
314314
}
315315

src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher2.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ public function match($rawPathinfo)
371371
}
372372
not_nonsecure:
373373

374-
if ('/' === $pathinfo) {
374+
if ('/' === $pathinfo && !$allow) {
375375
throw new Symfony\Component\Routing\Exception\NoConfigurationException();
376376
}
377377

src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher3.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function match($rawPathinfo)
4646
return array('_route' => 'with-condition');
4747
}
4848

49-
if ('/' === $pathinfo) {
49+
if ('/' === $pathinfo && !$allow) {
5050
throw new Symfony\Component\Routing\Exception\NoConfigurationException();
5151
}
5252

src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher4.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public function match($rawPathinfo)
103103

104104
}
105105

106-
if ('/' === $pathinfo) {
106+
if ('/' === $pathinfo && !$allow) {
107107
throw new Symfony\Component\Routing\Exception\NoConfigurationException();
108108
}
109109

src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher5.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ public function match($rawPathinfo)
200200

201201
}
202202

203-
if ('/' === $pathinfo) {
203+
if ('/' === $pathinfo && !$allow) {
204204
throw new Symfony\Component\Routing\Exception\NoConfigurationException();
205205
}
206206

src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher6.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ public function match($rawPathinfo)
204204

205205
}
206206

207-
if ('/' === F438 $pathinfo) {
207+
if ('/' === $pathinfo && !$allow) {
208208
throw new Symfony\Component\Routing\Exception\NoConfigurationException();
209209
}
210210

src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher7.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ public function match($rawPathinfo)
240240

241241
}
242242

243-
if ('/' === $pathinfo) {
243+
if ('/' === $pathinfo && !$allow) {
244244
throw new Symfony\Component\Routing\Exception\NoConfigurationException();
245245
}
246246

src/Symfony/Component/Routing/Tests/Matcher/UrlMatcherTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,21 @@ public function testMethodNotAllowed()
4545
}
4646
}
4747

48+
public function testMethodNotAllowedOnRoot()
49+
{
50+
$coll = new RouteCollection();
51+
$coll->add('foo', new Route('/', array(), array(), array(), '', array(), array('GET')));
52+
53+
$matcher = $this->getUrlMatcher($coll, new RequestContext('', 'POST'));
54+
55+
try {
56+
$matcher->match('/');
57+
$this->fail();
58+
} catch (MethodNotAllowedException $e) {
59+
$this->assertEquals(array('GET'), $e->getAllowedMethods());
60+
}
61+
}
62+
4863
public function testHeadAllowedWhenRequirementContainsGet()
4964
{
5065
$coll = new RouteCollection();

0 commit comments

Comments
 (0)
0