diff --git a/core/lib/Drupal/Core/Theme/Registry.php b/core/lib/Drupal/Core/Theme/Registry.php index 6d591f9953..65eb44d3c1 100644 --- a/core/lib/Drupal/Core/Theme/Registry.php +++ b/core/lib/Drupal/Core/Theme/Registry.php @@ -237,25 +237,26 @@ protected function init($theme_name = NULL) { */ public function get() { $this->init($this->themeName); - if (!$this->cacheGet()) { - // If called from inside a fiber, suspend it, this may allow another code - // path to begin an asynchronous operation before we do the CPU-intensive - // task of building the theme registry. - if (\Fiber::getCurrent() !== NULL) { - \Fiber::suspend(); - // When we return from the fiber being suspended, check the cache again - // since it may have been built in the meantime, either in this process - // or via a different request altogether. - if ($cached = $this->cacheGet()) { - return $cached; - } - } - $this->build(); - // Only persist it if all modules are loaded to ensure it is complete. - if ($this->moduleHandler->isLoaded()) { - $this->setCache(); + if ($cached = $this->cacheGet()) { + return $cached; + } + // If called from inside a fiber, suspend it, this may allow another code + // path to begin an asynchronous operation before we do the CPU-intensive + // task of building the theme registry. + if (\Fiber::getCurrent() !== NULL) { + \Fiber::suspend(); + // When we return from the fiber being suspended, check the cache again + // since it may have been built in the meantime, either in this process + // or via a different request altogether. + if ($cached = $this->cacheGet()) { + return $cached; } } + $this->build(); + // Only persist it if all modules are loaded to ensure it is complete. + if ($this->moduleHandler->isLoaded()) { + $this->setCache(); + } return $this->registry[$this->theme->getName()]; }