From bb92523035783def461fef64b588f1ac1bf5a6a8 Mon Sep 17 00:00:00 2001
From: webchick <webchick@24967.no-reply.drupal.org>
Date: Sun, 22 Sep 2013 00:03:20 +0200
Subject: [PATCH] =?UTF-8?q?Issue=20#2094797=20by=20dawehner,=20G=C3=A1bor?=
 =?UTF-8?q?=20Hojtsy,=20webflo:=20Fixed=20Config=20entities=20upcast=20fro?=
 =?UTF-8?q?m=20the=20request=20always=20get=20default=20language=20context?=
 =?UTF-8?q?.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../Drupal/locale/LocaleConfigSubscriber.php  |  4 ++-
 .../Tests/LocaleConfigTranslationTest.php     | 25 +++++++++++++++++--
 2 files changed, 26 insertions(+), 3 deletions(-)

diff --git a/core/modules/locale/lib/Drupal/locale/LocaleConfigSubscriber.php b/core/modules/locale/lib/Drupal/locale/LocaleConfigSubscriber.php
index cb9be7389dac..11fa899a4751 100644
--- a/core/modules/locale/lib/Drupal/locale/LocaleConfigSubscriber.php
+++ b/core/modules/locale/lib/Drupal/locale/LocaleConfigSubscriber.php
@@ -134,7 +134,9 @@ public function getLocaleConfigName($name, Language $language) {
   static function getSubscribedEvents() {
     $events['config.context'][] = array('configContext', 20);
     $events['config.load'][] = array('configLoad', 20);
-    $events[KernelEvents::REQUEST][] = array('onKernelRequestSetDefaultConfigContextLocale', 20);
+    // Set the priority above the one from the RouteListener (priority 32)
+    // so ensure that the context is cleared before the routing system steps in.
+    $events[KernelEvents::REQUEST][] = array('onKernelRequestSetDefaultConfigContextLocale', 48);
     return $events;
   }
 }
diff --git a/core/modules/locale/lib/Drupal/locale/Tests/LocaleConfigTranslationTest.php b/core/modules/locale/lib/Drupal/locale/Tests/LocaleConfigTranslationTest.php
index 6ad570a5d2e2..8fa1ff00cb3f 100644
--- a/core/modules/locale/lib/Drupal/locale/Tests/LocaleConfigTranslationTest.php
+++ b/core/modules/locale/lib/Drupal/locale/Tests/LocaleConfigTranslationTest.php
@@ -21,7 +21,7 @@ class LocaleConfigTranslationTest extends WebTestBase {
    *
    * @var array
    */
-  public static $modules = array('locale');
+  public static $modules = array('locale', 'contact');
 
   public static function getInfo() {
     return array(
@@ -43,7 +43,7 @@ public function setUp() {
   function testConfigTranslation() {
     // Add custom language.
     $langcode = 'xx';
-    $admin_user = $this->drupalCreateUser(array('administer languages', 'access administration pages', 'translate interface', 'administer modules'));
+    $admin_user = $this->drupalCreateUser(array('administer languages', 'access administration pages', 'translate interface', 'administer modules', 'access site-wide contact form'));
     $this->drupalLogin($admin_user);
     $name = $this->randomName(16);
     $edit = array(
@@ -144,6 +144,27 @@ function testConfigTranslation() {
 
     // Ensure that the translated configuration has been removed.
     $this->assertFalse(\Drupal::config('locale.config.xx.image.style.medium')->get('label'), 'Translated configuration for image module removed.');
+
+    // Translate default category using the UI so configuration is refreshed.
+    $category_label = $this->randomName(20);
+    $search = array(
+      'string' => 'Website feedback',
+      'langcode' => $langcode,
+      'translation' => 'all',
+    );
+    $this->drupalPostForm('admin/config/regional/translate', $search, t('Filter'));
+    $textarea = current($this->xpath('//textarea'));
+    $lid = (string) $textarea[0]['name'];
+    $edit = array(
+      $lid => $category_label,
+    );
+    $this->drupalPostForm('admin/config/regional/translate', $edit, t('Save translations'));
+
+    // Check if this category displayed in this language will use the
+    // translation. This test ensures the entity loaded from the request
+    // upcasting will already work.
+    $this->drupalGet($langcode . '/contact/feedback');
+    $this->assertText($category_label);
   }
 
 }
-- 
GitLab