Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 08fbf74

Browse filesBrowse files
committed
Fixed unexpected 404 NoConfigurationException
1 parent 3fc97ce commit 08fbf74
Copy full SHA for 08fbf74

File tree

3 files changed

+11
-18
lines changed
Filter options

3 files changed

+11
-18
lines changed

‎src/Symfony/Component/Routing/Matcher/Dumper/PhpMatcherTrait.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Routing/Matcher/Dumper/PhpMatcherTrait.php
+6-10Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function match($pathinfo)
4242
throw new MethodNotAllowedException(array_keys($allow));
4343
}
4444
if (!$this instanceof RedirectableUrlMatcherInterface) {
45-
throw new ResourceNotFoundException();
45+
throw new ResourceNotFoundException(sprintf('No routes found for "%s".', $pathinfo));
4646
}
4747
if (!\in_array($this->context->getMethod(), ['HEAD', 'GET'], true)) {
4848
// no-op
@@ -67,7 +67,7 @@ public function match($pathinfo)
6767
}
6868
}
6969

70-
throw new ResourceNotFoundException();
70+
throw new ResourceNotFoundException(sprintf('No routes found for "%s".', $pathinfo));
7171
}
7272

7373
private function doMatch(string $pathinfo, array &$allow = [], array &$allowSchemes = []): array
@@ -110,10 +110,8 @@ private function doMatch(string $pathinfo, array &$allow = [], array &$allowSche
110110
}
111111

112112
$hasRequiredScheme = !$requiredSchemes || isset($requiredSchemes[$context->getScheme()]);
113-
if ($requiredMethods && !isset($requiredMethods[$canonicalMethod]) && !isset($requiredMethods[$requestMethod])) {
114-
if ($hasRequiredScheme) {
115-
$allow += $requiredMethods;
116-
}
113+
if ($hasRequiredScheme && $requiredMethods && !isset($requiredMethods[$canonicalMethod]) && !isset($requiredMethods[$requestMethod])) {
114+
$allow += $requiredMethods;
117115
continue;
118116
}
119117

@@ -158,10 +156,8 @@ private function doMatch(string $pathinfo, array &$allow = [], array &$allowSche
158156
}
159157

160158
$hasRequiredScheme = !$requiredSchemes || isset($requiredSchemes[$context->getScheme()]);
161-
if ($requiredMethods && !isset($requiredMethods[$canonicalMethod]) && !isset($requiredMethods[$requestMethod])) {
162-
if ($hasRequiredScheme) {
163-
$allow += $requiredMethods;
164-
}
159+
if ($hasRequiredScheme && $requiredMethods && !isset($requiredMethods[$canonicalMethod]) && !isset($requiredMethods[$requestMethod])) {
160+
$allow += $requiredMethods;
165161
continue;
166162
}
167163
if (!$hasRequiredScheme) {

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Routing/Matcher/UrlMatcher.php
+4-8Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public function match($pathinfo)
8989
return $ret;
9090
}
9191

92-
if ('/' === $pathinfo && !$this->allow) {
92+
if ('/' === $pathinfo && !$this->allow && !$this->allowSchemes) {
9393
throw new NoConfigurationException();
9494
}
9595

@@ -187,14 +187,10 @@ protected function matchCollection($pathinfo, RouteCollection $routes)
187187
}
188188

189189
$hasRequiredScheme = !$route->getSchemes() || $route->hasScheme($this->context->getScheme());
190-
if ($requiredMethods) {
191-
if (!\in_array($method, $requiredMethods)) {
192-
if ($hasRequiredScheme) {
193-
$this->allow = array_merge($this->allow, $requiredMethods);
194-
}
190+
if ($hasRequiredScheme && $requiredMethods && !\in_array($method, $requiredMethods)) {
191+
$this->allow = array_merge($this->allow, $requiredMethods);
195192

196-
continue;
197-
}
193+
continue;
198194
}
199195

200196
if (!$hasRequiredScheme) {

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Routing/Tests/Matcher/UrlMatcherTest.php
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -727,6 +727,7 @@ public function testNestedCollections()
727727

728728
/**
729729
* @expectedException \Symfony\Component\Routing\Exception\ResourceNotFoundException
730+
* @expectedExceptionMessage No routes found for "/".
730731
*/
731732
public function testSchemeAndMethodMismatch()
732733
{

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.