Commit c07014d6 authored by catch's avatar catch

Issue #1899994 by katbailey, plach, YesCT: Fixed Disentangle language...

Issue #1899994 by katbailey, plach, YesCT: Fixed Disentangle language initialization from path resolution.
parent b574b9e5
......@@ -81,10 +81,13 @@ public function onKernelRequestFrontPageResolve(GetResponseEvent $event) {
* The Event to process.
*/
public function onKernelRequestLanguageResolve(GetResponseEvent $event) {
$request = $event->getRequest();
$path = _language_resolved_path();
if ($path !== NULL) {
$this->setPath($request, $path);
// We need to act only on the master request, otherwise subrequests will
// inherit the main request path and an infinite loop will be started.
if ($event->getRequestType() == HttpKernelInterface::MASTER_REQUEST) {
$path = _language_resolved_path();
if ($path !== NULL) {
$this->setPath($event->getRequest(), $path);
}
}
}
......
......@@ -19,7 +19,7 @@ class LanguageUrlRewritingTest extends WebTestBase {
*
* @var array
*/
public static $modules = array('language');
public static $modules = array('language', 'language_test');
public static function getInfo() {
return array(
......@@ -59,6 +59,10 @@ function testUrlRewritingEdgeCases() {
$non_existing = language_default();
$non_existing->langcode = $this->randomName();
$this->checkUrl($non_existing, 'Path language is ignored if language is not installed.', 'URL language negotiation does not work with non-installed languages');
// Check that URL rewriting is not applied to subrequests.
$this->drupalGet('language_test/subrequest');
$this->assertText($this->web_user->name, 'Page correctly retrieved');
}
/**
......
......@@ -5,6 +5,9 @@
* Mock module for language layer tests.
*/
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\HttpKernelInterface;
/**
* Implements hook_init().
*/
......@@ -94,3 +97,25 @@ function language_test_store_language_negotiation() {
function language_test_language_negotiation_method($languages) {
return 'it';
}
/**
* Implements hook_menu().
*/
function language_test_menu() {
$items = array();
$items['language_test/subrequest'] = array(
'page callback' => 'language_test_subrequest',
'access callback' => TRUE,
'type' => MENU_CALLBACK,
);
return $items;
}
/**
* Page callback. Uses a subrequest to retrieve the 'user' page.
*/
function language_test_subrequest() {
return drupal_container()->get('http_kernel')->handle(Request::create('/user'), HttpKernelInterface::SUB_REQUEST);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment