Issue #1572394 by attiks, Sweetchuck: Fixed Language detection by domain only works on port 80.

merge-requests/26/head
David Rothstein 2012-06-09 16:16:19 -04:00
parent 988597f0df
commit 4777845d4f
3 changed files with 9 additions and 2 deletions

View File

@ -16,6 +16,7 @@ Drupal 7.15, xxxx-xx-xx (development version)
may access the language using entity_language() (API change). may access the language using entity_language() (API change).
- Fixed regression: The first plural index on a page was not calculated - Fixed regression: The first plural index on a page was not calculated
correctly. correctly.
- Fixed bug: Language detection by domain only worked on port 80.
Drupal 7.14 2012-05-02 Drupal 7.14 2012-05-02
---------------------- ----------------------

View File

@ -279,6 +279,12 @@ function locale_language_from_url($languages) {
break; break;
case LOCALE_LANGUAGE_NEGOTIATION_URL_DOMAIN: case LOCALE_LANGUAGE_NEGOTIATION_URL_DOMAIN:
// Get only the host, not the port.
$http_host= $_SERVER['HTTP_HOST'];
if (strpos($http_host, ':') !== FALSE) {
$http_host_tmp = explode(':', $http_host);
$http_host = current($http_host_tmp);
}
foreach ($languages as $language) { foreach ($languages as $language) {
// Skip check if the language doesn't have a domain. // Skip check if the language doesn't have a domain.
if ($language->domain) { if ($language->domain) {
@ -286,7 +292,7 @@ function locale_language_from_url($languages) {
// Remove protocol and add http:// so parse_url works // Remove protocol and add http:// so parse_url works
$host = 'http://' . str_replace(array('http://', 'https://'), '', $language->domain); $host = 'http://' . str_replace(array('http://', 'https://'), '', $language->domain);
$host = parse_url($host, PHP_URL_HOST); $host = parse_url($host, PHP_URL_HOST);
if ($_SERVER['HTTP_HOST'] == $host) { if ($http_host == $host) {
$language_url = $language->language; $language_url = $language->language;
break; break;
} }

View File

@ -2378,7 +2378,7 @@ class LocaleUILanguageNegotiationTest extends DrupalWebTestCase {
array( array(
'language_negotiation' => array(LOCALE_LANGUAGE_NEGOTIATION_URL, LANGUAGE_NEGOTIATION_DEFAULT), 'language_negotiation' => array(LOCALE_LANGUAGE_NEGOTIATION_URL, LANGUAGE_NEGOTIATION_DEFAULT),
'locale_language_negotiation_url_part' => LOCALE_LANGUAGE_NEGOTIATION_URL_DOMAIN, 'locale_language_negotiation_url_part' => LOCALE_LANGUAGE_NEGOTIATION_URL_DOMAIN,
'locale_test_domain' => $language_domain, 'locale_test_domain' => $language_domain . ':88',
'path' => 'admin/config', 'path' => 'admin/config',
'expect' => $language_string, 'expect' => $language_string,
'expected_provider' => LOCALE_LANGUAGE_NEGOTIATION_URL, 'expected_provider' => LOCALE_LANGUAGE_NEGOTIATION_URL,