Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Display the Welcome Page when there is no homepage defined#26041

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed

Conversation

@javiereguiluz
Copy link
Member

QA
Branch?3.4
Bug fix?yes
New feature?no
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed ticketssymfony/symfony-docs#9178
LicenseMIT
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 thewebsite-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 (seesymfony/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.

yceruto, hhamon, Koc, and StayCoolDK reacted with thumbs up emoji
@nicolas-grekas
Copy link
Member

I'm +1 on the intend.
The UrlMatcher class also needs an update, and the corresponding tests I suppose.

@sroze
Copy link
Contributor

Definitely 👍

@yceruto
Copy link
Member

yceruto commentedFeb 4, 2018
edited
Loading

Hey Javier, I like your proposal and in the same direction we might need to make some additional changes:

The phrase... and you haven't configured any URLs. could be incomplete now. What about finishing this statement with... at root path. or something similar?

You're seeing this message because you have debug mode enabled and you haven't configured any URLs.

According to your idea, this part should also be updated:

if (0 ===count($this->routes) &&'/' ===$pathinfo) {
thrownewNoConfigurationException();
}

Related fixtures that require updating (files):

array($collection,'url_matcher1.php',array()),
array($redirectCollection,'url_matcher2.php',array('base_class' =>'Symfony\Component\Routing\Tests\Fixtures\RedirectableUrlMatcher')),
array($rootprefixCollection,'url_matcher3.php',array()),
array($headMatchCasesCollection,'url_matcher4.php',array()),
array($groupOptimisedCollection,'url_matcher5.php',array('base_class' =>'Symfony\Component\Routing\Tests\Fixtures\RedirectableUrlMatcher')),
array($trailingSlashCollection,'url_matcher6.php',array()),
array($trailingSlashCollection,'url_matcher7.php',array('base_class' =>'Symfony\Component\Routing\Tests\Fixtures\RedirectableUrlMatcher')),

In the other hand, I have a concern now about the name/description of this exception, because it does not fit his new scenario, i.e. it'll be thrown even with routes configuration:

/**
* Exception thrown when no routes are configured.
*
* @author Yonel Ceruto <yonelceruto@gmail.com>
*/
class NoConfigurationExceptionextends ResourceNotFoundException
{
}

Do you think we can add another exceptionNoRootConfiguration extends NoConfiguration and throw it instead? In that case we might need deprecate theNoConfiguration class or use it only when'' === $code:

$code .="        if ('/' ===\$pathinfo) {\n";if ('' ===$code) {$code .="            throw new Symfony\Component\Routing\Exception\NoConfigurationException();\n";}else {$code .="            throw new Symfony\Component\Routing\Exception\NoRootConfigurationException();\n";}$code .="        }\n";

@nicolas-grekasnicolas-grekas added this to the3.4 milestoneFeb 5, 2018
@nicolas-grekas
Copy link
Member

NoRootConfiguration extends NoConfiguration

I think it doesn't matter much, let's keep things simple IMHO

@nicolas-grekas
Copy link
Member

Status: needs work

@ChrisWMichel
Copy link

So is there a quick fix?

@sunnz
Copy link

I found this affects 4.0 too. (I just started following the getting started guide with 4.0.)

But I see that this is about the 3.4 branch and the other 4.0 pull requests and issues are closed... so I am wondering if this fix will apply to 4.x too?

ChrisWMichel reacted with thumbs up emoji

@javiereguiluz
Copy link
MemberAuthor

@yceruto I'm sorry but I don't know how to make the changes you mentioned inUrlMatcher.php andPhpMatcherDumperTest.php. Can you please give me more details ... or maybe you can take over this PR? Thanks!

@yceruto
Copy link
Member

yceruto commentedMar 9, 2018
edited
Loading

About the changes inUrlMatcher you need to remove this statement:0 === count($this->routes) && fromhere, thus we're removing"there are no routes defined" constraint.

And the fixtures related toPhpMatcherDumperTest.php need to be re-dumped. See the diffhere.

@javiereguiluz
Copy link
MemberAuthor

@yceruto thanks for your great help! I made the change and tests are now green. Ready for review!

@fabpot
Copy link
Member

Thank you@javiereguiluz.

fabpot added a commit that referenced this pull requestMar 11, 2018
… (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 (seesymfony/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
@fabpotfabpot closed thisMar 11, 2018
@settermjd
Copy link

Hey@javiereguiluz, will this be ported to the 4.0 branch?

@javiereguiluz
Copy link
MemberAuthor

Yes. Pull requests are periodically merged from lower to upper maintained branches, so this will end up in 4.0 and master too. Here is the list of maintained branches:https://symfony.com/roadmap

@mario6097
Copy link

mario6097 commentedMar 22, 2018
edited
Loading

Fedora 26, Symfony 4.0., just installed (bycomposer create-project symfony/website-skeleton my-project, i update byhttps://github.com/symfony/demo/blob/master/composer.json too).
I get a "No route found for "GET /" error.".
Do you have a fix? Is there a composer command to install it? Thks

@yceruto
Copy link
Member

@mario6097 It's already fixed, butit has not been released yet.

This was referencedApr 3, 2018
@idildin
Copy link

I use jms/i18n-routing-bundle and update symfony to 3.4.7 and i have problem with this feature.
My config usestrategy: prefix and this situation when referring to / must be a redirect to locale url. But showing homepage without redirect /{locale}
This problem is inPhpMatcherDumper.php
@javiereguiluz

@odie2
Copy link

Same like@idildin.
I just updated Symfony from 3.4.6 and now can't get default locale prefix redirect, while it was working like a charm before.

composer.json

"jms/i18n-routing-bundle": "2.0.x-dev",

routing.yml

main_index:    path:     /    defaults: { _controller: AppBundle:Main:index }    methods:  [GET]

config.yml

parameters:    locale: pl    app.languagesSlugs: [ en, pl ]framework:    default_locale:  "%locale%"# JMS I18N Routingjms_i18n_routing:    default_locale: pl    locales: "%app.languagesSlugs%"    strategy: prefix

http://localhost:8000/ - Welcome Page (before redirect tohttp://localhost:8000/pl/)

My question is: should I wait to fix by JMS I18N Routing bundle or by Symfony or is there any workaround to force default language redirect?

@nicolas-grekas
Copy link
Member

Please open dedicated issues instead: you won't get any attention by commenting on closed ones.

@mickaelandrieu
Copy link
Contributor

mickaelandrieu commentedMay 29, 2018
edited
Loading

Also, this is a BC for everyone involving in progressive migration to Symfony =>https://github.com/PrestaShop/PrestaShop/blob/develop/admin-dev/index.php#L87

I can't imagine what motivated you to change the behavior in an LTS :/

Any workaround?

EDIT: nevermind, it's already fixed with the latest 3.4, thanks :)

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@fabpotfabpotfabpot approved these changes

@ycerutoycerutoyceruto approved these changes

+1 more reviewer

@sstoksstoksstok approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

3.4

Development

Successfully merging this pull request may close these issues.

14 participants

@javiereguiluz@nicolas-grekas@sroze@yceruto@ChrisWMichel@sunnz@fabpot@settermjd@mario6097@idildin@odie2@mickaelandrieu@sstok@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp