Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[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

Closed
wants to merge 2 commits into from

Conversation

jfsimon
Copy link
Contributor

@jfsimon jfsimon commented Mar 14, 2013

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

@@ -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)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing space after if

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

fabpot added a commit that referenced this pull request Mar 18, 2013
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
@fabpot fabpot closed this Mar 18, 2013
$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());
Copy link
Member

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.

Copy link
Contributor Author

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...

jfsimon added a commit to jfsimon/symfony that referenced this pull request Mar 20, 2013
This reverts commit 70ec4f6, reversing
changes made to 3a03f3e.
fabpot added a commit that referenced this pull request Mar 20, 2013
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
fabpot added a commit that referenced this pull request Mar 23, 2013
* 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
fabpot added a commit that referenced this pull request Mar 23, 2013
* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants