diff -u b/core/core.services.yml b/core/core.services.yml --- b/core/core.services.yml +++ b/core/core.services.yml @@ -1197,7 +1197,7 @@ arguments: ['@app.root', '@theme_handler', '@state', '@module_handler'] theme.registry: class: Drupal\Core\Theme\Registry - arguments: ['@app.root', '@cache.default', '@lock', '@module_handler', '@theme_handler', '@theme.initialization', '@request_stack'] + arguments: ['@app.root', '@cache.default', '@lock', '@module_handler', '@theme_handler', '@theme.initialization'] tags: - { name: needs_destruction } calls: @@ -1208,7 +1208,7 @@ arguments: ['@app.root', '@theme_handler', '@state', '@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', '@request_stack'] tags: - { name: needs_destruction } calls: 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 @@ -82,11 +82,11 @@ } /** - * Gets the persistable. + * Whether the partial registry can be persisted to the cache. * * @return bool */ - protected function getPersistable() { + protected function isPersistable() { if ($this->persistable === NULL) { $this->persistable = $this->modulesLoaded && $this->requestStack->getCurrentRequest() !== NULL && $this->requestStack->getCurrentRequest()->isMethod('GET'); } @@ -101,7 +101,7 @@ */ protected function getStorage() { if (!$this->storage) { - if ($this->getPersistable() && $cached = $this->cache->get($this->getCid())) { + if ($this->isPersistable() && $cached = $this->cache->get($this->getCid())) { $this->storage = $cached->data; } else { @@ -172,7 +172,7 @@ } $storage = $this->getStorage(); $storage[$key] = $this->completeRegistry[$key]; - if ($this->getPersistable()) { + if ($this->isPersistable()) { $this->persist($key); } return $storage[$key]; @@ -182,7 +182,7 @@ * {@inheritdoc} */ protected function updateCache($lock = TRUE) { - if (!$this->getPersistable()) { + if (!$this->isPersistable()) { return; } // @todo: Is the custom implementation necessary? diff -u b/core/modules/system/src/Tests/Theme/RegistryTest.php b/core/modules/system/src/Tests/Theme/RegistryTest.php --- b/core/modules/system/src/Tests/Theme/RegistryTest.php +++ b/core/modules/system/src/Tests/Theme/RegistryTest.php @@ -73,12 +73,13 @@ public function testMultipleSubThemes() { $theme_handler = \Drupal::service('theme_handler'); $theme_handler->install(['test_basetheme', 'test_subtheme', 'test_subsubtheme']); + $request_stack = \Drupal::service('request_stack'); - $registry_subsub_theme = new Registry(\Drupal::root(), \Drupal::cache(), \Drupal::lock(), \Drupal::moduleHandler(), $theme_handler, \Drupal::service('theme.initialization'), 'test_subsubtheme'); + $registry_subsub_theme = new Registry(\Drupal::root(), \Drupal::cache(), \Drupal::lock(), \Drupal::moduleHandler(), $theme_handler, \Drupal::service('theme.initialization'), $request_stack, 'test_subsubtheme'); $registry_subsub_theme->setThemeManager(\Drupal::theme()); - $registry_sub_theme = new Registry(\Drupal::root(), \Drupal::cache(), \Drupal::lock(), \Drupal::moduleHandler(), $theme_handler, \Drupal::service('theme.initialization'), 'test_subtheme'); + $registry_sub_theme = new Registry(\Drupal::root(), \Drupal::cache(), \Drupal::lock(), \Drupal::moduleHandler(), $theme_handler, \Drupal::service('theme.initialization'), $request_stack, 'test_subtheme'); $registry_sub_theme->setThemeManager(\Drupal::theme()); - $registry_base_theme = new Registry(\Drupal::root(), \Drupal::cache(), \Drupal::lock(), \Drupal::moduleHandler(), $theme_handler, \Drupal::service('theme.initialization'), 'test_basetheme'); + $registry_base_theme = new Registry(\Drupal::root(), \Drupal::cache(), \Drupal::lock(), \Drupal::moduleHandler(), $theme_handler, \Drupal::service('theme.initialization'), $request_stack, 'test_basetheme'); $registry_base_theme->setThemeManager(\Drupal::theme()); $preprocess_functions = $registry_subsub_theme->get()['theme_test_template_test']['preprocess functions']; @@ -113,7 +114,7 @@ $theme_handler->install(['test_theme']); $theme_handler->setDefault('test_theme'); - $registry = new Registry(\Drupal::root(), \Drupal::cache(), \Drupal::lock(), \Drupal::moduleHandler(), $theme_handler, \Drupal::service('theme.initialization'), 'test_theme'); + $registry = new Registry(\Drupal::root(), \Drupal::cache(), \Drupal::lock(), \Drupal::moduleHandler(), $theme_handler, \Drupal::service('theme.initialization'), \Drupal::service('request_stack'), 'test_theme'); $registry->setThemeManager(\Drupal::theme()); $this->assertEqual('value', $registry->get()['theme_test_template_test']['variables']['additional']); } only in patch2: unchanged: --- a/core/tests/Drupal/Tests/Core/Theme/RegistryTest.php +++ b/core/tests/Drupal/Tests/Core/Theme/RegistryTest.php @@ -66,6 +66,8 @@ class RegistryTest extends UnitTestCase { */ protected $themeManager; + protected $requestStack; + /** * {@inheritdoc} */ @@ -78,6 +80,7 @@ protected function setUp() { $this->themeHandler = $this->getMock('Drupal\Core\Extension\ThemeHandlerInterface'); $this->themeInitialization = $this->getMock('Drupal\Core\Theme\ThemeInitializationInterface'); $this->themeManager = $this->getMock('Drupal\Core\Theme\ThemeManagerInterface'); + $this->requestStack = $this->getMock('Symfony\Component\HttpFoundation\RequestStack'); $this->setupTheme(); } @@ -131,7 +134,7 @@ public function testGetRegistryForModule() { } protected function setupTheme($theme_name = NULL) { - $this->registry = new TestRegistry($this->root, $this->cache, $this->lock, $this->moduleHandler, $this->themeHandler, $this->themeInitialization, $theme_name); + $this->registry = new TestRegistry($this->root, $this->cache, $this->lock, $this->moduleHandler, $this->themeHandler, $this->themeInitialization, $this->requestStack, $theme_name); $this->registry->setThemeManager($this->themeManager); }