From 94ae1793a13cb9cffcbdff4ebef3a030ee2231fa Mon Sep 17 00:00:00 2001
From: Nathaniel Catchpole <catch@35733.no-reply.drupal.org>
Date: Fri, 28 Oct 2016 12:46:19 +0100
Subject: [PATCH] Revert "Revert "Issue #2761403 by Berdir: Move runtime theme
 registry into bootstrap cache""

This reverts commit d189ff056cd1629a668a9ce767a8cac6473b549b.
---
 core/core.services.yml                  |  2 +-
 core/lib/Drupal/Core/Theme/Registry.php | 14 ++++++++++++--
 2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/core/core.services.yml b/core/core.services.yml
index 850bb3542d1f..08b422c15ff1 100644
--- a/core/core.services.yml
+++ b/core/core.services.yml
@@ -1447,7 +1447,7 @@ services:
     arguments: ['@app.root', '@theme_handler', '@cache.bootstrap', '@module_handler']
   theme.registry:
     class: Drupal\Core\Theme\Registry
-    arguments: ['@app.root', '@cache.default', '@lock', '@module_handler', '@theme_handler', '@theme.initialization']
+    arguments: ['@app.root', '@cache.default', '@lock', '@module_handler', '@theme_handler', '@theme.initialization', null, '@cache.bootstrap']
     tags:
       - { name: needs_destruction }
     calls:
diff --git a/core/lib/Drupal/Core/Theme/Registry.php b/core/lib/Drupal/Core/Theme/Registry.php
index 6f5cb1e7ce3c..0cb00a639298 100644
--- a/core/lib/Drupal/Core/Theme/Registry.php
+++ b/core/lib/Drupal/Core/Theme/Registry.php
@@ -140,6 +140,13 @@ class Registry implements DestructableInterface {
    */
   protected $themeManager;
 
+  /**
+   * The runtime cache.
+   *
+   * @var \Drupal\Core\Cache\CacheBackendInterface
+   */
+  protected $runtimeCache;
+
   /**
    * Constructs a \Drupal\Core\Theme\Registry object.
    *
@@ -157,8 +164,10 @@ class Registry implements DestructableInterface {
    *   The theme initialization.
    * @param string $theme_name
    *   (optional) The name of the theme for which to construct the registry.
+   * @param \Drupal\Core\Cache\CacheBackendInterface $runtime_cache
+   *   The cache backend interface to use for the runtime theme registry data.
    */
-  public function __construct($root, CacheBackendInterface $cache, LockBackendInterface $lock, ModuleHandlerInterface $module_handler, ThemeHandlerInterface $theme_handler, ThemeInitializationInterface $theme_initialization, $theme_name = NULL) {
+  public function __construct($root, CacheBackendInterface $cache, LockBackendInterface $lock, ModuleHandlerInterface $module_handler, ThemeHandlerInterface $theme_handler, ThemeInitializationInterface $theme_initialization, $theme_name = NULL, CacheBackendInterface $runtime_cache = NULL) {
     $this->root = $root;
     $this->cache = $cache;
     $this->lock = $lock;
@@ -166,6 +175,7 @@ public function __construct($root, CacheBackendInterface $cache, LockBackendInte
     $this->themeName = $theme_name;
     $this->themeHandler = $theme_handler;
     $this->themeInitialization = $theme_initialization;
+    $this->runtimeCache = $runtime_cache;
   }
 
   /**
@@ -239,7 +249,7 @@ public function get() {
   public function getRuntime() {
     $this->init($this->themeName);
     if (!isset($this->runtimeRegistry[$this->theme->getName()])) {
-      $this->runtimeRegistry[$this->theme->getName()] = new ThemeRegistry('theme_registry:runtime:' . $this->theme->getName(), $this->cache, $this->lock, array('theme_registry'), $this->moduleHandler->isLoaded());
+      $this->runtimeRegistry[$this->theme->getName()] = new ThemeRegistry('theme_registry:runtime:' . $this->theme->getName(), $this->runtimeCache ?: $this->cache, $this->lock, array('theme_registry'), $this->moduleHandler->isLoaded());
     }
     return $this->runtimeRegistry[$this->theme->getName()];
   }
-- 
GitLab