8000 bug #26041 Display the Welcome Page when there is no homepage defined… · symfony/symfony@2655496 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2655496

Browse files
committed
bug #26041 Display the Welcome Page when there is no homepage defined (javiereguiluz)
This PR was squashed before being merged into the 3.4 branch (closes #26041). Discussion ---------- Display the Welcome Page when there is no homepage defined | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | symfony/symfony-docs#9178 | License | MIT | Doc PR | - In 3.4 we added a trick to display the Welcome Page when the user browses `/` and there are no routes defined. However, when using the `website-skeleton` (which is what most newcomers use ... and they are the ones that mostly need the "Welcome Page") the premise about *"no routes are defined"* is never true and the Welcome Page is never shown (see symfony/symfony-docs#9178 for one of the multiple error reports we've received). So, I propose to make this change to always define the "Welcome Page" as the fallback: * If no routes are defined for `/`, the Welcome Page is displayed. * If there is a route defined for `/`, this code will never be executed because it's the last condition of the routing matcher. Commits ------- 5b0d934 Display the Welcome Page when there is no homepage defined
2 parents 07cccd5 + 5b0d934 commit 2655496

File tree

10 files changed

+34
-7
lines changed

10 files changed

+34
-7
lines changed

src/Symfony/Component/HttpKernel/Resources/welcome.html.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
</div>
7777
<div id="comment">
7878
<p>
79-
You're seeing this message because you have debug mode enabled and you haven't configured any URLs.
79+
You're seeing this page because debug mode is enabled and you haven't configured any homepage URL.
8080
</p>
8181
</div>
8282
</div>

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -153,11 +153,10 @@ private function compileRoutes(RouteCollection $routes, $supportsRedirections)
153153
}
154154
}
155155

156-
if ('' === $code) {
157-
$code .= " if ('/' === \$pathinfo) {\n";
158-
$code .= " throw new Symfony\Component\Routing\Exception\NoConfigurationException();\n";
159-
$code .= " }\n";
160-
}
156+
// used to display the Welcome Page in apps that don't define a homepage
157+
$code .= " if ('/' === \$pathinfo) {\n";
158+
$code .= " throw new Symfony\Component\Routing\Exception\NoConfigurationException();\n";
159+
$code .= " }\n";
161160

162161
return $code;
163162
}

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 (0 === count($this->routes) && '/' === $pathinfo) {
79+
if ('/' === $pathinfo) {
8080
throw new NoConfigurationException();
8181
}
8282

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,10 @@ public function match($rawPathinfo)
309309

310310
}
311311

312+
if ('/' === $pathinfo) {
313+
throw new Symfony\Component\Routing\Exception\NoConfigurationException();
314+
}
315+
312316
throw 0 < count($allow) ? new MethodNotAllowedException(array_unique($allow)) : new ResourceNotFoundException();
313317
}
314318
}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,10 @@ public function match($rawPathinfo)
371371
}
372372
not_nonsecure:
373373

374+
if ('/' === $pathinfo) {
375+
throw new Symfony\Component\Routing\Exception\NoConfigurationException();
376+
}
377+
374378
throw 0 < count($allow) ? new MethodNotAllowedException(array_unique($allow)) : new ResourceNotFoundException();
375379
}
376380
}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ public function match($rawPathinfo)
4646
return array('_route' => 'with-condition');
4747
}
4848

49+
if ('/' === $pathinfo) {
50+
throw new Symfony\Component\Routing\Exception\NoConfigurationException();
51+
}
52+
4953
throw 0 < count($allow) ? new MethodNotAllowedException(array_unique($allow)) : new ResourceNotFoundException();
5054
}
5155
}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,10 @@ public function match($rawPathinfo)
103103

104104
}
105105

106+
if ('/' === $pathinfo) {
107+
throw new Symfony\Component\Routing\Exception\NoConfigurationException();
108+
}
109+
106110
throw 0 < count($allow) ? new MethodNotAllowedException(array_unique($allow)) : new ResourceNotFoundException();
107111
}
108112
}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,10 @@ public function match($rawPathinfo)
200200

201201
}
202202

203+
if ('/' === $pathinfo) {
204+
throw new Symfony\Component\Routing\Exception\NoConfigurationException();
205+
}
206+
203207
throw 0 < count($allow) ? new MethodNotAllowedException(array_unique($allow)) : new ResourceNotFoundException();
204208
}
205209
}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,10 @@ public function match($rawPathinfo)
204204

205205
}
206206

207+
if ('/' === $pathinfo) {
208+
throw new Symfony\Component\Routing\Exception\NoConfigurationException();
209+
}
210+
207211
throw 0 < count($allow) ? new MethodNotAllowedException(array_unique($allow)) : new ResourceNotFoundException();
208212
}
209213
}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,10 @@ public function match($rawPathinfo)
240240

241241
}
242242

243+
if ('/' === $pathinfo) {
244+
throw new Symfony\Component\Routing\Exception\NoConfigurationException();
245+
}
246+
243247
throw 0 < count($allow) ? new MethodNotAllowedException(array_unique($allow)) : new ResourceNotFoundException();
244248
}
245249
}

0 commit comments

Comments
 (0)
0