diff --git a/core/lib/Drupal/Core/Asset/LibraryDiscoveryParser.php b/core/lib/Drupal/Core/Asset/LibraryDiscoveryParser.php index 75107e1..f6de366 100644 --- a/core/lib/Drupal/Core/Asset/LibraryDiscoveryParser.php +++ b/core/lib/Drupal/Core/Asset/LibraryDiscoveryParser.php @@ -336,15 +336,11 @@ protected function parseLibraryInfo($extension, $path) { protected function applyLibrariesOverride($libraries, $extension) { $active_theme = $this->themeManager->getActiveTheme(); $libraries_overrides = $active_theme->getLibrariesOverride(); - $valid_libraries = []; foreach ($libraries as $name => $library) { // Process libraries overrides. foreach ($libraries_overrides as $asset => $override) { // Active theme defines an override for this library. if ($asset === "$extension/$name") { - // Keep track of libraries-overrides that are valid. - $valid_libraries[] = $asset; - // The active theme defines an override for the whole library. Use the // override key to specify that this library will be overridden when // it is called. @@ -382,9 +378,6 @@ protected function applyLibrariesOverride($libraries, $extension) { $key_exists = NULL; $attributes = NestedArray::getValue($libraries[$name], $parents, $key_exists); if ($key_exists) { - // Keep track of libraries-overrides that are valid. - $valid_libraries[] = $asset; - // Remove asset to be overridden, but keep its attributes. NestedArray::unsetValue($libraries[$name], $parents); if ($override) { @@ -395,11 +388,6 @@ protected function applyLibrariesOverride($libraries, $extension) { } } } - // Remaining libraries-override definitions not in $valid_libraries are - // likely invalid. Throw an exception. - if ($invalid_libraries = array_diff(array_keys($libraries_overrides), $valid_libraries)) { - throw new InvalidLibrariesOverrideSpecificationException(sprintf('Overridden library asset(s) "%s" could not be found.', implode(', ', $invalid_libraries))); - } return $libraries; } diff --git a/core/modules/system/src/Tests/Asset/LibraryDiscoveryIntegrationTest.php b/core/modules/system/src/Tests/Asset/LibraryDiscoveryIntegrationTest.php index 9ef0fc6..7d7c7b9 100644 --- a/core/modules/system/src/Tests/Asset/LibraryDiscoveryIntegrationTest.php +++ b/core/modules/system/src/Tests/Asset/LibraryDiscoveryIntegrationTest.php @@ -29,7 +29,7 @@ protected function setUp() { /** * Ensures that the element info can be altered by themes. */ - public function ptestElementInfoByTheme() { + public function testElementInfoByTheme() { /** @var \Drupal\Core\Theme\ThemeInitializationInterface $theme_initializer */ $theme_initializer = $this->container->get('theme.initialization'); @@ -46,7 +46,7 @@ public function ptestElementInfoByTheme() { /** * Tests that libraries-override are applied to library definitions. */ - public function ptestLibrariesOverride() { + public function testLibrariesOverride() { /** @var \Drupal\Core\Theme\ThemeInitializationInterface $theme_initializer */ $theme_initializer = $this->container->get('theme.initialization'); @@ -85,7 +85,7 @@ public function ptestLibrariesOverride() { /** * Tests libraries-override on drupalSettings. */ - public function ptestLibrariesOverrideDrupalSettings() { + public function testLibrariesOverrideDrupalSettings() { $this->container->get('theme_handler')->install(['test_theme_libraries_override_with_drupal_settings']); /** @var \Drupal\Core\Theme\ThemeInitializationInterface $theme_initializer */ @@ -113,7 +113,7 @@ public function ptestLibrariesOverrideDrupalSettings() { /** * Tests libraries-override on malformed assets. */ - public function ptestLibrariesOverrideMalformedAsset() { + public function testLibrariesOverrideMalformedAsset() { $this->container->get('theme_handler')->install(['test_theme_libraries_override_with_invalid_asset']); /** @var \Drupal\Core\Theme\ThemeInitializationInterface $theme_initializer */ @@ -141,7 +141,7 @@ public function ptestLibrariesOverrideMalformedAsset() { /** * Tests library assets with other ways for specifying paths. */ - public function ptestLibrariesOverrideOtherAssetLibraryNames() { + public function testLibrariesOverrideOtherAssetLibraryNames() { $this->container->get('theme_handler')->install(['test_theme']); /** @var \Drupal\Core\Theme\ThemeInitializationInterface $theme_initializer */ @@ -175,7 +175,7 @@ public function ptestLibrariesOverrideOtherAssetLibraryNames() { /** * Tests that base theme libraries-override still apply in sub themes. */ - public function ptestBaseThemeLibrariesOverrideInSubTheme() { + public function testBaseThemeLibrariesOverrideInSubTheme() { $this->container->get('theme_handler')->install(['test_subtheme']); /** @var \Drupal\Core\Theme\ThemeInitializationInterface $theme_initializer */ @@ -199,34 +199,6 @@ public function ptestBaseThemeLibrariesOverrideInSubTheme() { } /** - * Tests libraries-override on non-existent assets specifications on LHS. - */ - public function testLibrariesOverrideNonExistentLhs() { - $this->container->get('theme_handler')->install(['test_theme_libraries_override_non_existing']); - - /** @var \Drupal\Core\Theme\ThemeInitializationInterface $theme_initializer */ - $theme_initializer = $this->container->get('theme.initialization'); - - /** @var \Drupal\Core\Theme\ThemeManagerInterface $theme_manager */ - $theme_manager = $this->container->get('theme.manager'); - - /** @var \Drupal\Core\Render\ElementInfoManagerInterface $element_info */ - $library_discovery = $this->container->get('library.discovery'); - - $theme_manager->setActiveTheme($theme_initializer->getActiveThemeByName('test_theme_libraries_override_non_existing')); - - // Assert that improperly formed asset "specs" throw an exception. - try { - $library_discovery->getLibraryByName('core', 'drupal.dialog'); - $this->fail('Throw Exception when specifying non-existent override'); - } - catch (InvalidLibrariesOverrideSpecificationException $e) { - $expected_message = 'Overridden library asset(s) "core/drupal.dialogs, core/drupal.dropbutton/css/components/misc/dropbutton/dropbutton.css" could not be found.'; - $this->assertEqual($e->getMessage(), $expected_message, 'Throw Exception when specifying non-existent override'); - } - } - - /** * Asserts that the given asset is in the specified library. * * @param mixed $library_item diff --git a/core/modules/system/tests/themes/test_theme_libraries_override_non_existing/test_theme_libraries_override_non_existing.info.yml b/core/modules/system/tests/themes/test_theme_libraries_override_non_existing/test_theme_libraries_override_non_existing.info.yml deleted file mode 100644 index a86d3bf..0000000 --- a/core/modules/system/tests/themes/test_theme_libraries_override_non_existing/test_theme_libraries_override_non_existing.info.yml +++ /dev/null @@ -1,14 +0,0 @@ -name: 'Test theme libraries-override' -type: theme -description: 'Theme with non-existent libraries-override asset spec.' -version: VERSION -base theme: classy -core: 8.x -libraries-override: - # A non-existent library asset specified for overriding. Should throw a - # \Drupal\Core\Asset\Exception\InvalidLibrariesOverrideSpecificationException. - # Left-hand side typos. - core/drupal.dialogs: false - core/drupal.dropbutton/css/components/misc/dropbutton/dropbutton.css: /themes/my_theme/css/dropbutton.css - # Right-hand side non-existing library. - core/drupal.collapse: test_theme/collapses