diff --git a/core/lib/Drupal/Core/Asset/AssetResolver.php b/core/lib/Drupal/Core/Asset/AssetResolver.php index 3c1256c..343a893 100644 --- a/core/lib/Drupal/Core/Asset/AssetResolver.php +++ b/core/lib/Drupal/Core/Asset/AssetResolver.php @@ -114,10 +114,11 @@ protected function getLibrariesToLoad(AttachedAssetsInterface $assets) { * {@inheritdoc} */ public function getCssAssets(AttachedAssetsInterface $assets, $optimize) { + $theme_info = $this->themeManager->getActiveTheme(); // Add the theme name to the cache key since themes may implement // hook_library_info_alter(). - $theme_info = $this->themeManager->getActiveTheme(); - $cid = 'css:' . $theme_info->getName() . ':' . Crypt::hashBase64(serialize($this->getLibrariesToLoad($assets))) . (int) $optimize; + $libraries_to_load = $this->getLibrariesToLoad($assets); + $cid = 'css:' . $theme_info->getName() . ':' . Crypt::hashBase64(serialize($libraries_to_load)) . (int) $optimize; if ($cached = $this->cache->get($cid)) { return $cached->data; } @@ -132,7 +133,7 @@ public function getCssAssets(AttachedAssetsInterface $assets, $optimize) { 'browsers' => [], ]; - foreach ($this->getLibrariesToLoad($assets) as $library) { + foreach ($libraries_to_load as $library) { list($extension, $name) = explode('/', $library, 2); $definition = $this->libraryDiscovery->getLibraryByName($extension, $name); if (isset($definition['css'])) { @@ -212,10 +213,11 @@ protected function getJsSettingsAssets(AttachedAssetsInterface $assets) { * {@inheritdoc} */ public function getJsAssets(AttachedAssetsInterface $assets, $optimize) { + $theme_info = $this->themeManager->getActiveTheme(); // Add the theme name to the cache key since themes may implement // hook_library_info_alter(). - $theme_info = $this->themeManager->getActiveTheme(); - $cid = 'js:' . $theme_info->getName() . ':' . Crypt::hashBase64(serialize($this->getLibrariesToLoad($assets))) . (int) $optimize; + $libraries_to_load = $this->getLibrariesToLoad($assets); + $cid = 'js:' . $theme_info->getName() . ':' . Crypt::hashBase64(serialize($libraries_to_load)) . (int) $optimize; if ($cached = $this->cache->get($cid)) { list($js_assets_header, $js_assets_footer, $settings, $settings_in_header) = $cached->data; @@ -233,8 +235,6 @@ public function getJsAssets(AttachedAssetsInterface $assets, $optimize) { 'browsers' => [], ]; - $libraries_to_load = $this->getLibrariesToLoad($assets); - // Collect all libraries that contain JS assets and are in the header. $header_js_libraries = []; foreach ($libraries_to_load as $library) {