diff --git a/core/lib/Drupal/Core/Asset/LibraryDiscovery.php b/core/lib/Drupal/Core/Asset/LibraryDiscovery.php index 5b5c811..46ad1ed 100644 --- a/core/lib/Drupal/Core/Asset/LibraryDiscovery.php +++ b/core/lib/Drupal/Core/Asset/LibraryDiscovery.php @@ -7,6 +7,7 @@ namespace Drupal\Core\Asset; +use Drupal\Core\Cache\Cache; use Drupal\Core\Cache\CacheBackendInterface; use Drupal\Core\Extension\ModuleHandlerInterface; @@ -112,7 +113,7 @@ protected function loadLibraryDefinitions() { } else { $libraries = $this->discoveryParser->build(); - $this->cache->set($this->cacheKey, $libraries); + $this->cache->set($this->cacheKey, $libraries, Cache::PERMANENT, ['extension']); } // @todo Should themes be able to take part in this process as well? diff --git a/core/modules/system/src/Form/ThemeAdminForm.php b/core/modules/system/src/Form/ThemeAdminForm.php index 2cee8c5..9cf656c 100644 --- a/core/modules/system/src/Form/ThemeAdminForm.php +++ b/core/modules/system/src/Form/ThemeAdminForm.php @@ -52,6 +52,7 @@ public function buildForm(array $form, FormStateInterface $form_state, array $th public function submitForm(array &$form, FormStateInterface $form_state) { drupal_set_message($this->t('The configuration options have been saved.')); $this->config('system.theme')->set('admin', $form_state->getValue('admin_theme'))->save(); + \Drupal::cache('discovery')->delete('library_info'); } } diff --git a/core/modules/system/src/Tests/Common/JavaScriptTest.php b/core/modules/system/src/Tests/Common/JavaScriptTest.php index a59d50e..a2c6089 100644 --- a/core/modules/system/src/Tests/Common/JavaScriptTest.php +++ b/core/modules/system/src/Tests/Common/JavaScriptTest.php @@ -612,7 +612,7 @@ function testGetLibrary() { $library_discovery = \Drupal::service('library.discovery'); // Retrieve all libraries registered by a module. $libraries = $library_discovery->getLibrariesByExtension('common_test'); - $this->assertTrue(isset($libraries['jquery.farbtastic']), 'Retrieved all module libraries.'); + $this->assertTrue(isset($libraries['common_test/jquery.farbtastic']), 'Retrieved all module libraries.'); // Retrieve all libraries for a module not declaring any libraries. // Note: This test installs language module. $libraries = $library_discovery->getLibrariesByExtension('dblog'); diff --git a/core/tests/Drupal/Tests/Core/Asset/LibraryDiscoveryParserTest.php b/core/tests/Drupal/Tests/Core/Asset/LibraryDiscoveryParserTest.php index 0c3fbff..5cd2776 100644 --- a/core/tests/Drupal/Tests/Core/Asset/LibraryDiscoveryParserTest.php +++ b/core/tests/Drupal/Tests/Core/Asset/LibraryDiscoveryParserTest.php @@ -143,8 +143,14 @@ public function testBuildByExtensionWithMissingLibraryFile() { 'example_module' => new Extension($this->root, 'module', $path . '/example_module.info.yml') ]); - - $this->assertSame($this->libraryDiscoveryParser->build(), []); + $result = $this->libraryDiscoveryParser->build(); + foreach ($result as $library_name => $library) { + if (strpos($library_name, 'core/') === 0) { + unset($result[$library_name]); + } + } + + $this->assertSame($result, []); } /**