From e303b674a2fd22383203bb45a95b768e6497959f Mon Sep 17 00:00:00 2001 From: catch <catch@35733.no-reply.drupal.org> Date: Thu, 24 May 2012 15:14:06 +0900 Subject: [PATCH] Issue #1572394 by attiks, Sweetchuck: Fixed Language detection by domain only works on port 80. --- core/modules/language/language.negotiation.inc | 7 ++++++- core/modules/language/language.test | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/core/modules/language/language.negotiation.inc b/core/modules/language/language.negotiation.inc index 4d560e7d361d..a16dbe82ce5a 100644 --- a/core/modules/language/language.negotiation.inc +++ b/core/modules/language/language.negotiation.inc @@ -220,6 +220,11 @@ function language_from_url($languages) { break; case LANGUAGE_NEGOTIATION_URL_DOMAIN: + // Get only the host, not the port. + $http_host= $_SERVER['HTTP_HOST']; + if (strpos($http_host, ':') !== FALSE) { + $http_host = current(explode(':', $http_host)); + } $domains = language_negotiation_url_domains(); foreach ($languages as $language) { // Skip the check if the language doesn't have a domain. @@ -228,7 +233,7 @@ function language_from_url($languages) { // the hostname. $host = 'http://' . str_replace(array('http://', 'https://'), '', $domains[$language->langcode]); $host = parse_url($host, PHP_URL_HOST); - if ($_SERVER['HTTP_HOST'] == $host) { + if ($http_host == $host) { $language_url = $language->langcode; break; } diff --git a/core/modules/language/language.test b/core/modules/language/language.test index d48f2a9e8206..d931dc6a9957 100644 --- a/core/modules/language/language.test +++ b/core/modules/language/language.test @@ -706,7 +706,7 @@ class LanguageUILanguageNegotiationTestCase extends WebTestBase { array( 'language_negotiation' => array(LANGUAGE_NEGOTIATION_URL, LANGUAGE_NEGOTIATION_DEFAULT), 'language_negotiation_url_part' => LANGUAGE_NEGOTIATION_URL_DOMAIN, - 'language_test_domain' => $language_domain, + 'language_test_domain' => $language_domain . ':88', 'path' => 'admin/config', 'expect' => $language_string, 'expected_method_id' => LANGUAGE_NEGOTIATION_URL, -- GitLab