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 c5ffda8

Browse filesBrowse files
committed
Fixed unexpected 404 NoConfigurationException
1 parent e479b69 commit c5ffda8
Copy full SHA for c5ffda8

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
@@ -39,7 +39,7 @@ public function match($pathinfo)
3939
throw new MethodNotAllowedException(array_keys($allow));
4040
}
4141
if (!$this instanceof RedirectableUrlMatcherInterface) {
42-
throw new ResourceNotFoundException();
42+
throw new ResourceNotFoundException(sprintf('No routes found for "%s".', $pathinfo));
4343
}
4444
if (!\in_array($this->context->getMethod(), ['HEAD', 'GET'], true)) {
4545
// no-op
@@ -64,7 +64,7 @@ public function match($pathinfo)
6464
}
6565
}
6666

67-
throw new ResourceNotFoundException();
67+
throw new ResourceNotFoundException(sprintf('No routes found for "%s".', $pathinfo));
6868
}
6969

7070
private function doMatch(string $pathinfo, array &$allow = [], array &$allowSchemes = []): array
@@ -107,10 +107,8 @@ private function doMatch(string $pathinfo, array &$allow = [], array &$allowSche
107107
}
108108

109109
$hasRequiredScheme = !$requiredSchemes || isset($requiredSchemes[$context->getScheme()]);
110-
if ($requiredMethods && !isset($requiredMethods[$canonicalMethod]) && !isset($requiredMethods[$requestMethod])) {
111-
if ($hasRequiredScheme) {
112-
$allow += $requiredMethods;
113-
}
110+
if ($hasRequiredScheme && $requiredMethods && !isset($requiredMethods[$canonicalMethod]) && !isset($requiredMethods[$requestMethod])) {
111+
$allow += $requiredMethods;
114112
continue;
115113
}
116114
if (!$hasRequiredScheme) {
@@ -154,10 +152,8 @@ private function doMatch(string $pathinfo, array &$allow = [], array &$allowSche
154152
}
155153

156154
$hasRequiredScheme = !$requiredSchemes || isset($requiredSchemes[$context->getScheme()]);
157-
if ($requiredMethods && !isset($requiredMethods[$canonicalMethod]) && !isset($requiredMethods[$requestMethod])) {
158-
if ($hasRequiredScheme) {
159-
$allow += $requiredMethods;
160-
}
155+
if ($hasRequiredScheme && $requiredMethods && !isset($requiredMethods[$canonicalMethod]) && !isset($requiredMethods[$requestMethod])) {
156+
$allow += $requiredMethods;
161157
continue;
162158
}
163159
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
@@ -88,7 +88,7 @@ public function match($pathinfo)
8888
return $ret;
8989
}
9090

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

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

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

195-
continue;
196-
}
192+
continue;
197193
}
198194

199195
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
@@ -582,6 +582,7 @@ public function testNestedCollections()
582582

583583
/**
584584
* @expectedException \Symfony\Component\Routing\Exception\ResourceNotFoundException
585+
* @expectedExceptionMessage No routes found for "/".
585586
*/
586587
public function testSchemeAndMethodMismatch()
587588
{

0 commit comments

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