From a3d8888369f3fc31e74720452d2718e089a77cb2 Mon Sep 17 00:00:00 2001
From: webchick <webchick@24967.no-reply.drupal.org>
Date: Sun, 15 Dec 2013 09:57:31 -0800
Subject: [PATCH] =?UTF-8?q?Issue=20#2008270=20by=20typhonius,=20mcjim,=20W?=
 =?UTF-8?q?im=20Leers,=20vijaycs85,=20mr.baileys,=20JohnAlbin:=20Remove=20?=
 =?UTF-8?q?drupal=5Fadd=5Fcss()=20from=20template=5Fpreprocess=5Fmaintenan?=
 =?UTF-8?q?ce=5Fpage()=20=E2=80=94=20use=20#attached.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 core/includes/theme.inc             | 34 +++++++++++++++++++----------
 core/includes/theme.maintenance.inc |  5 -----
 core/modules/system/system.module   | 18 +++++++++++----
 3 files changed, 37 insertions(+), 20 deletions(-)

diff --git a/core/includes/theme.inc b/core/includes/theme.inc
index dd50e62779eb..aaa3b74c5c5c 100644
--- a/core/includes/theme.inc
+++ b/core/includes/theme.inc
@@ -2358,6 +2358,8 @@ function theme_get_suggestions($args, $base, $delimiter = '__') {
  * @param array $variables
  *   An associative array containing:
  *   - content - An array of page content.
+ *
+ * @see system_page_build()
  */
 function template_preprocess_maintenance_page(&$variables) {
   global $theme;
@@ -2424,21 +2426,31 @@ function template_preprocess_maintenance_page(&$variables) {
       $head_title['slogan'] = strip_tags(filter_xss_admin($site_slogan));
     }
   }
-  $path = drupal_get_path('module', 'system');
 
   // These are usually added from system_page_build() except maintenance.css.
   // When the database is inactive it's not called so we add it here.
-  $default_css = array(
-    '#attached' => array(
-      'css' => array(
-        $path . '/css/system.module.css',
-        $path . '/css/system.theme.css',
-        $path . '/css/system.admin.css',
-        $path . '/css/system.maintenance.css',
-      ),
-    ),
+  $default_css['library'][] = array('system', 'normalize');
+  $path = drupal_get_path('module', 'system');
+  // Adjust the weights to load these early.
+  $default_css['css'][$path . '/css/system.module.css'] = array(
+    'weight' => CSS_COMPONENT - 10,
+    'every_page' => TRUE,
+  );
+  $default_css['css'][$path . '/css/system.theme.css'] = array(
+    'weight' => CSS_SKIN - 10,
+    'every_page' => TRUE,
+  );
+  // Unlike regular pages, the admin.css is added for every maintenance page.
+  $default_css['css'][$path . '/css/system.admin.css'] = array(
+    'weight' => CSS_COMPONENT - 10,
+    'every_page' => TRUE,
+  );
+  $default_css['css'][$path . '/css/system.maintenance.css'] = array(
+    'weight' => CSS_COMPONENT - 10,
+    'every_page' => TRUE,
   );
-  drupal_render($default_css);
+  $attached = array('#attached' => $default_css);
+  drupal_render($attached);
 
   $variables['head_title_array']  = $head_title;
   $variables['head_title']        = implode(' | ', $head_title);
diff --git a/core/includes/theme.maintenance.inc b/core/includes/theme.maintenance.inc
index 807566cd1567..96dcd2f90af0 100644
--- a/core/includes/theme.maintenance.inc
+++ b/core/includes/theme.maintenance.inc
@@ -95,11 +95,6 @@ function _drupal_maintenance_theme() {
   // Prime the theme registry.
   // @todo Remove global theme variables.
   Drupal::service('theme.registry');
-
-  // These CSS files are normally added by system_page_build(), except
-  // system.maintenance.css. When the database is inactive, it's not called so
-  // we add them here.
-  drupal_add_library('system', 'normalize');
 }
 
 /**
diff --git a/core/modules/system/system.module b/core/modules/system/system.module
index 9500adf830a6..c725d8a7a0f0 100644
--- a/core/modules/system/system.module
+++ b/core/modules/system/system.module
@@ -2116,16 +2116,26 @@ function system_filetransfer_info() {
 
 /**
  * Implements hook_page_build().
+ *
+ * @see template_preprocess_maintenance_page()
  */
 function system_page_build(&$page) {
-  // Note: ensure the same CSS is loaded in _drupal_maintenance_theme().
+  // Ensure the same CSS is loaded in template_preprocess_maintenance_page().
   $page['#attached']['library'][] = array('system', 'normalize');
   $path = drupal_get_path('module', 'system');
   // Adjust the weights to load these early.
-  $page['#attached']['css'][$path . '/css/system.module.css'] = array('weight' => CSS_COMPONENT - 10, 'every_page' => TRUE);
-  $page['#attached']['css'][$path . '/css/system.theme.css'] = array('weight' => CSS_SKIN - 10, 'every_page' => TRUE);
+  $page['#attached']['css'][$path . '/css/system.module.css'] = array(
+    'weight' => CSS_COMPONENT - 10,
+    'every_page' => TRUE,
+  );
+  $page['#attached']['css'][$path . '/css/system.theme.css'] = array(
+    'weight' => CSS_SKIN - 10,
+    'every_page' => TRUE,
+  );
   if (path_is_admin(current_path())) {
-    $page['#attached']['css'][$path . '/css/system.admin.css'] = array('weight' => CSS_COMPONENT - 10);
+    $page['#attached']['css'][$path . '/css/system.admin.css'] = array(
+      'weight' => CSS_COMPONENT - 10,
+    );
   }
 }
 
-- 
GitLab