reverted: --- b/core/lib/Drupal/Core/Theme/Registry.php +++ a/core/lib/Drupal/Core/Theme/Registry.php @@ -236,7 +236,7 @@ public function getRuntime() { $this->init($this->themeName); if (!isset($this->runtimeRegistry)) { + $this->runtimeRegistry = new ThemeRegistry('theme_registry:runtime:' . $this->theme->getName(), $this->cache, $this->lock, array('theme_registry'), $this->moduleHandler->isLoaded()); - $this->runtimeRegistry = new ThemeRegistry($this->cache, $this->lock, $this->theme, array('theme_registry'), $this->moduleHandler->isLoaded()); } return $this->runtimeRegistry; } diff -u b/core/lib/Drupal/Core/Utility/ThemeRegistry.php b/core/lib/Drupal/Core/Utility/ThemeRegistry.php --- b/core/lib/Drupal/Core/Utility/ThemeRegistry.php +++ b/core/lib/Drupal/Core/Utility/ThemeRegistry.php @@ -12,7 +12,6 @@ use Drupal\Core\Cache\CacheCollector; use Drupal\Core\DestructableInterface; use Drupal\Core\Lock\LockBackendInterface; -use Drupal\Core\Theme\ActiveTheme; /** * Builds the run-time theme registry. @@ -68,33 +67,12 @@ * @param bool $modules_loaded * Whether all modules have already been loaded. */ - function __construct(CacheBackendInterface $cache, LockBackendInterface $lock, ActiveTheme $theme, $tags = array(), $modules_loaded = FALSE) { + function __construct($cid, CacheBackendInterface $cache, LockBackendInterface $lock, $tags = array(), $modules_loaded = FALSE) { $this->cache = $cache; $this->lock = $lock; $this->tags = $tags; - $this->theme = $theme; - $this->modulesLoaded = $modules_loaded; - } - - /** - * {@inheritdoc} - */ - protected function getCid() { - if (!$this->cid) { - $this->cid = 'theme_registry:runtime:' . $this->theme->getName(); - } - - return $this->cid; - } - - /** - * Sets the cid. - * - * @param string $cid - * The cid for the array being cached. - */ - public function setCid($cid) { $this->cid = $cid; + $this->modulesLoaded = $modules_loaded; } /** @@ -110,7 +88,6 @@ return $this->persistable; } - /** * Gets the storage. * reverted: --- b/core/modules/system/src/Tests/Theme/RegistryTest.php +++ a/core/modules/system/src/Tests/Theme/RegistryTest.php @@ -34,20 +34,18 @@ // The theme registry is not marked as persistable in case we don't have a // proper request. \Drupal::request()->setMethod('GET'); + $cid = 'test_theme_registry'; // Directly instantiate the theme registry, this will cause a base cache // entry to be written in __construct(). $cache = \Drupal::cache(); $lock_backend = \Drupal::lock(); + $registry = new ThemeRegistry($cid, $cache, $lock_backend, array('theme_registry'), $this->container->get('module_handler')->isLoaded()); - $theme = \Drupal::theme(); - $registry = new ThemeRegistry($cache, $lock_backend, $theme->getActiveTheme(), array('theme_registry'), $this->container->get('module_handler')->isLoaded()); + $this->assertTrue(\Drupal::cache()->get($cid), 'Cache entry was created.'); - $cid = 'theme_registry:runtime:' . $theme->getActiveTheme()->getName(); - $this->assertFalse(\Drupal::cache()->get($cid), 'Cache entry was not created by default.'); // Trigger a cache miss for an offset. $this->assertTrue($registry->get('theme_test_template_test'), 'Offset was returned correctly from the theme registry.'); - $this->assertTrue(\Drupal::cache()->get($cid), 'Cache entry was created.'); // This will cause the ThemeRegistry class to write an updated version of // the cache entry when it is destroyed, usually at the end of the request. // Before that happens, manually delete the cache entry we created earlier @@ -62,42 +60,12 @@ // Create a new instance of the class. Confirm that both the offset // requested previously, and one that has not yet been requested are both // available. + $registry = new ThemeRegistry($cid, $cache, $lock_backend, array('theme_registry'), $this->container->get('module_handler')->isLoaded()); - $registry = new ThemeRegistry($cache, $lock_backend, $theme->getActiveTheme(), array('theme_registry'), $this->container->get('module_handler')->isLoaded()); $this->assertTrue($registry->get('theme_test_template_test'), 'Offset was returned correctly from the theme registry'); $this->assertTrue($registry->get('theme_test_template_test_2'), 'Offset was returned correctly from the theme registry'); } /** - * Tests the behavior of theme registry class when cid is set manually. - */ - public function testManualCidSet() { - // The theme registry is not marked as persistable in case we don't have a - // proper request. - \Drupal::request()->setMethod('GET'); - - // Directly instantiate the theme registry, this will cause a base cache - // entry to be written in __construct(). - $cache = \Drupal::cache(); - $lock_backend = \Drupal::lock(); - $theme = \Drupal::theme(); - $cid = 'kitten_theme_registry'; - $registry = new ThemeRegistry($cache, $lock_backend, $theme->getActiveTheme(), array('theme_registry'), $this->container->get('module_handler')->isLoaded()); - $registry->setCid($cid); - - $this->assertFalse(\Drupal::cache()->get($cid), 'Cache entry was not created by default.'); - - // Trigger a cache miss for an offset. - $this->assertTrue($registry->get('theme_test_template_test'), 'Offset was returned correctly from the theme registry.'); - $this->assertTrue(\Drupal::cache()->get($cid), 'Cache entry was created.'); - \Drupal::cache()->delete($cid); - - // Destroy the class so that it triggers a cache write for the offset. - $registry->destruct(); - - $this->assertTrue(\Drupal::cache()->get($cid), 'Cache entry was created.'); - } - - /** * Tests the theme registry with multiple subthemes. */ public function testMultipleSubThemes() {