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

[HttpKernel] Use Accept-Language header even if there are no enabled locales#47377

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

Merged
fabpot merged 1 commit intosymfony:6.2fromMatTheCat:ticket_47355
Sep 23, 2022

Conversation

@MatTheCat
Copy link
Contributor

@MatTheCatMatTheCat commentedAug 24, 2022
edited
Loading

QA
Branch?6.2
Bug fix?no
New feature?no
Deprecations?no
TicketsFix#47355
LicenseMIT
Doc PRN/A

Don’t really know how I should consider this PR 🤔

It would affect people settingset_locale_from_accept_language totrue with noenabled_locales when the request has a preferred language:

  • before: set the default locale as request locale
  • after: set the preferred language as request locale

@chalasr
Copy link
Member

Can you add a test case that breaks before your patch?

@MatTheCat
Copy link
ContributorAuthor

MatTheCat commentedAug 31, 2022
edited
Loading

@chalasr done.

While updatingtestRequestAttributeLocaleNotOverridenFromAcceptLanguageHeader I stumbled into a weird behavior which I think was caused by theAccept-Language header set the wrong way, so I updated tests doing this.

@MatTheCatMatTheCatforce-pushed theticket_47355 branch 2 times, most recently fromc20d409 to0a81366CompareSeptember 4, 2022 13:17
@MatTheCatMatTheCatforce-pushed theticket_47355 branch 2 times, most recently from89c118d to8a39eebCompareSeptember 19, 2022 06:23
@fabpot
Copy link
Member

@MatTheCat Can you create a PR on 4.4 for the tests fix?

@MatTheCat
Copy link
ContributorAuthor

MatTheCat commentedSep 21, 2022
edited
Loading

@fabpot see#47638 (concerned tests were added by#43108 on 5.4). Should I copy its changes on this PR? Else tests will fail until it is merged and rebased 🤔

symfony-splitter pushed a commit to symfony/http-kernel that referenced this pull requestSep 21, 2022
…ers (MatTheCat)This PR was merged into the 5.4 branch.Discussion----------[HttpKernel] Fix LocaleListenerTest Accept-Language headers| Q             | A| ------------- | ---| Branch?       | 5.4| Bug fix?      | yes| New feature?  | no| Deprecations? | no| Tickets       |Fixsymfony/symfony#47377 (comment)| License       | MIT| Doc PR        | N/ACommits-------b6ac197fa4 Fix LocaleListenerTest Accept-Language headers
@chalasrchalasr reopened thisSep 21, 2022
@chalasr
Copy link
Member

chalasr commentedSep 21, 2022
edited
Loading

Looks like because#47638's description included "Fix#47377(some comment)", github closed this PR automatically when merging#47638.

Should I copy its changes on this PR? Else tests will fail until it is merged and rebased 🤔

Rebase unlocked,#47638 has been merged up to 6.2.

@MatTheCat
Copy link
ContributorAuthor

Damn okay sorry 😅

PR rebased!

@chalasr
Copy link
Member

No worries, I'd say it should be improved on Github :)
Can you please add a small entry in the framework-bundle CHANGELOG?

@MatTheCat
Copy link
ContributorAuthor

Set locale from request rather that default locale if "framework.enabled_locales" is empty and "framework.set_locale_from_accept_language" is true

WDYT? Don’t really know how to make it shorter.

@chalasr
Copy link
Member

Works for me!

MatTheCat reacted with thumbs up emoji

@fabpot
Copy link
Member

Thank you@MatTheCat.

@nicolas-grekas
Copy link
Member

I'm a bit late here but this means we are going to always send the Vary: Accept-Language header, isn't it? I'm not sure this is legit.

@MatTheCatMatTheCat deleted the ticket_47355 branchSeptember 23, 2022 08:26
@MatTheCat
Copy link
ContributorAuthor

MatTheCat commentedSep 23, 2022
edited
Loading

@nicolas-grekas only ifset_locale_from_accept_language is true and theAccept-Language header contains some locales.

@nicolas-grekas
Copy link
Member

nicolas-grekas commentedSep 23, 2022
edited
Loading

Oh, thanks. Two other issues: why on 6.2 and not on 6.1? And more importantly: the vary header should also be sent when $preferredLanguage is falsy. The code should look like this:

        }elseif ($this->useAcceptLanguageHeader) {if ($preferredLanguage =$request->getPreferredLanguage($this->enabledLocales)) {$request->setLocale($preferredLanguage);            }$request->attributes->set('_vary_by_language',true);        }

Can you please send a PR on 6.1 if you agree?

@MatTheCat
Copy link
ContributorAuthor

I’m not sure about you two questions 😞 so I’ll wait for the approval of other members before submitting another PR.

@chalasr
Copy link
Member

Nicolas is right, please go ahead if you want/can.

MatTheCat added a commit to MatTheCat/symfony that referenced this pull requestSep 23, 2022
chalasr added a commit that referenced this pull requestSep 23, 2022
…no enabled locales (MatTheCat)This PR was squashed before being merged into the 6.1 branch.Discussion----------[HttpKernel] Use Accept-Language header even if there are no enabled locales| Q             | A| ------------- | ---| Branch?       | 6.1| Bug fix?      | yes| New feature?  | no| Deprecations? | no| Tickets       |Fix#47377| License       | MIT| Doc PR        | N/ACommits-------d97d51c [HttpKernel] Use Accept-Language header even if there are no enabled locales
@fabpotfabpot mentioned this pull requestOct 24, 2022
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@chalasrchalasrchalasr approved these changes

@fabpotfabpotfabpot approved these changes

Assignees

No one assigned

Projects

None yet

Milestone

6.2

Development

Successfully merging this pull request may close these issues.

framework.enabled_locales does not behave as documented

5 participants

@MatTheCat@chalasr@fabpot@nicolas-grekas@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp