diff --git a/core/modules/language/src/EventSubscriber/LanguageRequestSubscriber.php b/core/modules/language/src/EventSubscriber/LanguageRequestSubscriber.php index fbaa7a7..1147590 100644 --- a/core/modules/language/src/EventSubscriber/LanguageRequestSubscriber.php +++ b/core/modules/language/src/EventSubscriber/LanguageRequestSubscriber.php @@ -133,8 +133,7 @@ public function onKernelRequestLanguageRedirect(GetResponseEvent $event) { $request = $event->getRequest(); $can_redirect = $event->getRequestType() == HttpKernelInterface::MASTER_REQUEST && $request->isMethod('GET') - && !$request->query->has('destination') - && $this->currentRouteMatch->getRouteName() != 'user.logout'; + && !$request->query->has('destination'); if ($can_redirect) { // Construct URL to the current route. If it is different from the request // URL, then we assume that it was changed to match the detected language. @@ -144,11 +143,6 @@ public function onKernelRequestLanguageRedirect(GetResponseEvent $event) { 'absolute' => TRUE, ]; $redirect_uri = $this->urlGenerator->generateFromRoute($route_name, [], $options); - // As we want get the original URL, it is not safe to use - /* @see \Symfony\Component\HttpFoundation\Request::getUri() */ - // here because it uses - /* @see \Symfony\Component\HttpFoundation\Request::normalizeQueryString() */ - // which sorts query parameters. $original_uri = $request->getSchemeAndHttpHost() . $request->getRequestUri(); if ($redirect_uri != $original_uri) { $event->setResponse(new RedirectResponse($redirect_uri)); diff --git a/core/modules/language/src/Tests/LanguageListTest.php b/core/modules/language/src/Tests/LanguageListTest.php index 29f0d53..9a11139 100644 --- a/core/modules/language/src/Tests/LanguageListTest.php +++ b/core/modules/language/src/Tests/LanguageListTest.php @@ -45,6 +45,8 @@ function testLanguageList() { ); $this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add language')); $this->assertText('French', 'Language added successfully.'); + $this->rebuildContainer(); + \Drupal::service('router.builder')->rebuild(); $this->assertUrl(\Drupal::url('entity.configurable_language.collection', [], ['absolute' => TRUE])); // Get the weight of the last language and check that the weight is one unit @@ -154,7 +156,8 @@ function testLanguageList() { 'direction' => Language::DIRECTION_LTR, ); $this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add custom language')); - $this->resetAll(); + $this->rebuildContainer(); + \Drupal::service('router.builder')->rebuild(); $this->assertUrl(\Drupal::url('entity.configurable_language.collection', [], ['absolute' => TRUE])); $this->assertText($name, 'Name found.'); diff --git a/core/modules/language/src/Tests/LanguagePageCacheTest.php b/core/modules/language/src/Tests/LanguagePageCacheTest.php index 238c4d5..20f83b6 100644 --- a/core/modules/language/src/Tests/LanguagePageCacheTest.php +++ b/core/modules/language/src/Tests/LanguagePageCacheTest.php @@ -10,6 +10,7 @@ use Drupal\language\Entity\ConfigurableLanguage; use Drupal\Core\Language\Language; use Drupal\Core\Language\LanguageInterface; +use Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationUrl; use Drupal\simpletest\WebTestBase; /** @@ -59,7 +60,12 @@ protected function setUp() { function testPageCache() { $this->drupalGet('admin/config/regional/language/detection'); $this->setLanguageNegotiationOrder(); - $this->drupalGet('admin/config/regional/language/detection'); + $edit = array( + 'language_negotiation_url_part' => LanguageNegotiationUrl::CONFIG_PATH_PREFIX, + 'prefix[en]' => 'en', + 'prefix[fr]' => 'fr', + ); + $this->drupalPostForm('admin/config/regional/language/detection/url', $edit, t('Save configuration')); // Enable the language switching block. $block = $this->drupalPlaceBlock('language_block:' . LanguageInterface::TYPE_INTERFACE, array( @@ -73,7 +79,9 @@ function testPageCache() { $path = 'language_test/type-link-active-class'; - $this->drupalGet('fr/language_test/type-link-active-class'); + $this->drupalGet('language_test/type-link-active-class', array( + 'language' => $this->container->get('language_manager')->getLanguage('fr'), + )); $links = $this->getLinks($path); $this->assert($links['fr']['class'] == 'is-active', 'The "en" is defied'); @@ -103,6 +111,7 @@ public function setLanguageNegotiationOrder() { $language_negotiator->saveConfiguration(LanguageInterface::TYPE_INTERFACE, $method_weights); $this->config('language.types')->set('negotiation.' . LanguageInterface::TYPE_INTERFACE . '.method_weights', $method_weights)->save(); $this->rebuildContainer(); + \Drupal::service('router.builder')->rebuild(); } public function getPage($path, $langcode_browser_fallback='en') {