summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcatch2013-02-07 14:16:20 (GMT)
committercatch2013-02-07 14:16:20 (GMT)
commitc07014d65b2fcbac191aa0bd47e70ebadee9bef9 (patch)
tree90428c23adcd59dc9f72f3bbf5165e958d0103ed
parentb574b9e52da16875daa896714c7c370d14e20e09 (diff)
Issue #1899994 by katbailey, plach, YesCT: Fixed Disentangle language initialization from path resolution.
-rw-r--r--core/lib/Drupal/Core/EventSubscriber/PathSubscriber.php11
-rw-r--r--core/modules/language/lib/Drupal/language/Tests/LanguageUrlRewritingTest.php6
-rw-r--r--core/modules/language/tests/language_test/language_test.module25
3 files changed, 37 insertions, 5 deletions
diff --git a/core/lib/Drupal/Core/EventSubscriber/PathSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/PathSubscriber.php
index 698057b..6e5b7a9 100644
--- a/core/lib/Drupal/Core/EventSubscriber/PathSubscriber.php
+++ b/core/lib/Drupal/Core/EventSubscriber/PathSubscriber.php
@@ -81,10 +81,13 @@ class PathSubscriber extends PathListenerBase implements EventSubscriberInterfac
* 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);
+ }
}
}
diff --git a/core/modules/language/lib/Drupal/language/Tests/LanguageUrlRewritingTest.php b/core/modules/language/lib/Drupal/language/Tests/LanguageUrlRewritingTest.php
index 7cfa8c1..3effed4 100644
--- a/core/modules/language/lib/Drupal/language/Tests/LanguageUrlRewritingTest.php
+++ b/core/modules/language/lib/Drupal/language/Tests/LanguageUrlRewritingTest.php
@@ -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 @@ class LanguageUrlRewritingTest extends WebTestBase {
$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');
}
/**
diff --git a/core/modules/language/tests/language_test/language_test.module b/core/modules/language/tests/language_test/language_test.module
index e83f34c..cb97937 100644
--- a/core/modules/language/tests/language_test/language_test.module
+++ b/core/modules/language/tests/language_test/language_test.module
@@ -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);
+}