From 3cd094372c0a3ea4ccf396fccba5556c88b8e8b4 Mon Sep 17 00:00:00 2001
From: Alex Pott <alex.a.pott@googlemail.com>
Date: Tue, 8 Sep 2015 16:52:43 +0100
Subject: [PATCH] Issue #2548991 by Wim Leers, Mile23: Remove Bartik's
 erroneous use of drupal_process_attached(), add tests

---
 core/modules/color/color.module            |  4 ++++
 core/modules/color/src/Tests/ColorTest.php | 17 +++++++++++++++++
 core/themes/bartik/color/color.inc         | 14 ++++++++++----
 3 files changed, 31 insertions(+), 4 deletions(-)

diff --git a/core/modules/color/color.module b/core/modules/color/color.module
index 46ddce5f18ed..35cda30cfaeb 100644
--- a/core/modules/color/color.module
+++ b/core/modules/color/color.module
@@ -259,6 +259,10 @@ function color_scheme_form($complete_form, FormStateInterface $form_state, $them
     }
   }
   $form['theme'] = array('#type' => 'value', '#value' => $theme);
+  if (isset($info['#attached'])) {
+    $form['#attached'] = $info['#attached'];
+    unset($info['#attached']);
+  }
   $form['info'] = array('#type' => 'value', '#value' => $info);
 
   return $form;
diff --git a/core/modules/color/src/Tests/ColorTest.php b/core/modules/color/src/Tests/ColorTest.php
index 3456dca09526..1d1b72e334e8 100644
--- a/core/modules/color/src/Tests/ColorTest.php
+++ b/core/modules/color/src/Tests/ColorTest.php
@@ -177,4 +177,21 @@ function testValidColor() {
       }
     }
   }
+
+  /**
+   * Test whether the custom logo is used in the color preview.
+   */
+  function testLogoSettingOverride() {
+    $this->drupalLogin($this->bigUser);
+    $edit = array(
+      'default_logo' => FALSE,
+      'logo_path' => 'core/misc/druplicon.png',
+    );
+    $this->drupalPostForm('admin/appearance/settings', $edit, t('Save configuration'));
+
+    // Ensure that the overridden logo is present in Bartik, which is colorable.
+    $this->drupalGet('admin/appearance/settings/bartik');
+    $this->assertIdentical($GLOBALS['base_url'] . '/' . 'core/misc/druplicon.png', $this->getDrupalSettings()['color']['logo']);
+  }
+
 }
diff --git a/core/themes/bartik/color/color.inc b/core/themes/bartik/color/color.inc
index a498b2a8f548..4f42620d9c83 100644
--- a/core/themes/bartik/color/color.inc
+++ b/core/themes/bartik/color/color.inc
@@ -5,10 +5,6 @@
  * Lists available colors and color schemes for the Bartik theme.
  */
 
-// Put the logo path into JavaScript for the live preview.
-$js_attached['#attached']['drupalSettings']['color']['logo'] = theme_get_setting('logo.url', 'bartik');
-drupal_process_attached($js_attached);
-
 $info = array(
   // Available colors and color labels used in theme.
   'fields' => array(
@@ -121,4 +117,14 @@
   // Preview files.
   'preview_library' => 'bartik/color.preview',
   'preview_html' => 'color/preview.html',
+
+  // Attachments.
+  '#attached' => [
+    'drupalSettings' => [
+      'color' => [
+        // Put the logo path into JavaScript for the live preview.
+        'logo' => theme_get_setting('logo.url', 'bartik'),
+      ],
+    ],
+  ],
 );
-- 
GitLab