-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[HttpRequest] fixes Request::getLanguages() bug #7378
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -1309,6 +1309,11 @@ public function getLanguages() | |||
for ($i = 0, $max = count($codes); $i < $max; $i++) { | |||
if ($i == 0) { | |||
$lang = strtolower($codes[0]); | |||
// First segment of compound language codes | |||
// is added to supported languages list | |||
if(!in_array($lang, $this->languages)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing space after if
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
This PR was squashed before being merged into the 2.1 branch (closes #7378). Commits ------- 17dc2ff [HttpRequest] fixes Request::getLanguages() bug Discussion ---------- [HttpRequest] fixes Request::getLanguages() bug This PR adds to suported languages the first segment of all compouds languages codes. When receiving `Accept-Language: en-us` header, accepted languages will now be `en, en_US`. This should not be a BC break as most browsers already send the long **and** short versions of language codes... but some dont. | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #6928
$this->assertEquals(array('zh', 'en_US', 'en'), $request->getLanguages()); | ||
$this->assertEquals(array('zh', 'en_US', 'en'), $request->getLanguages()); | ||
$this->assertEquals(array('zh', 'en', 'en_US'), $request->getLanguages()); | ||
$this->assertEquals(array('zh', 'en', 'en_US'), $request->getLanguages()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jfsimon This is a BC break as en
would now be preferred over en_US
here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@stof oh, good one! I have not thought about the order...
This PR was merged into the 2.1 branch. Commits ------- c928ddc [HttpFoudantion] fixed Request::getPreferredLanguage() 839c78a Revert "merged branch jfsimon/issue-6928 (PR #7378)" Discussion ---------- [HttpFoundation] fixed Request::getPreferredLanguage() Previous PR #7378 was wrong and adding BC break. Resolution for short languages codes is now done in `Request::getPreferredLanguage()` method. | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #7378
* 2.1: #7106 - fix for ZTS builds Added '@@' escaping strategy for YamlFileLoader and YamlDumper [Yaml] fixed bugs with folded scalar parsing [Form] made DefaultCsrfProvider using session_status() when available Added unit tests to Dumper Update .travis.yml (closes #7355) [HttpFoudantion] fixed Request::getPreferredLanguage() Revert "merged branch jfsimon/issue-6928 (PR #7378)" Routing issue with installation in a sub-directory ref: #7129 Conflicts: .travis.yml src/Symfony/Bundle/FrameworkBundle/Routing/Router.php src/Symfony/Component/Routing/RouteCollection.php
* 2.2: #7106 - fix for ZTS builds Added '@@' escaping strategy for YamlFileLoader and YamlDumper [Yaml] fixed bugs with folded scalar parsing [Form] made DefaultCsrfProvider using session_status() when available Added unit tests to Dumper Update .travis.yml (closes #7355) [HttpFoudantion] fixed Request::getPreferredLanguage() Revert "merged branch jfsimon/issue-6928 (PR #7378)" Routing issue with installation in a sub-directory ref: #7129
This PR adds to suported languages the first segment of all compouds languages codes.
When receiving
Accept-Language: en-us
header, accepted languages will now been, en_US
.This should not be a BC break as most browsers already send the long and short versions of language codes... but some dont.