diff --git a/core/lib/Drupal/Core/Asset/Exception/InvalidLibrariesExtendSpecificationException.php b/core/lib/Drupal/Core/Asset/Exception/InvalidLibrariesExtendSpecificationException.php new file mode 100644 index 0000000..f1b9df0 --- /dev/null +++ b/core/lib/Drupal/Core/Asset/Exception/InvalidLibrariesExtendSpecificationException.php @@ -0,0 +1,15 @@ +themeManager->getActiveTheme()->getLibrariesExtend()["$extension/$library_name"])) { - $libraries_extend = $this->themeManager->getActiveTheme()->getLibrariesExtend()["$extension/$library_name"]; - foreach ($libraries_extend as $library_extend_name) { - list($new_extension, $new_library_name) = explode('/', $library_extend_name); + $active_theme = $this->themeManager->getActiveTheme()->getLibrariesExtend(); + if (!empty($active_theme["$extension/$library_name"])) { + foreach ($active_theme["$extension/$library_name"] as $library_extend_name) { + if (!is_string($library_extend_name)) { + // Only string library names are allowed. + throw new InvalidLibrariesExtendSpecificationException('The libraries-extend specification must be a string.'); + } + list($new_extension, $new_library_name) = explode('/', $library_extend_name, 2); $new_libraries = $this->get($new_extension); if (isset($new_libraries[$new_library_name])) { $library_definition = NestedArray::mergeDeep($library_definition, $new_libraries[$new_library_name]); } else { - throw new InvalidLibrariesOverrideSpecificationException(sprintf('The specified library %s does not exist.', $library_extend_name)); + throw new InvalidLibrariesExtendSpecificationException(sprintf('The specified library %s does not exist.', $library_extend_name)); } } } diff --git a/core/tests/Drupal/Tests/Core/Asset/LibraryDiscoveryCollectorTest.php b/core/tests/Drupal/Tests/Core/Asset/LibraryDiscoveryCollectorTest.php index 1c3733d..6199438 100644 --- a/core/tests/Drupal/Tests/Core/Asset/LibraryDiscoveryCollectorTest.php +++ b/core/tests/Drupal/Tests/Core/Asset/LibraryDiscoveryCollectorTest.php @@ -94,7 +94,7 @@ public function testResolveCacheMiss() { $this->activeTheme = $this->getMockBuilder('Drupal\Core\Theme\ActiveTheme') ->disableOriginalConstructor() ->getMock(); - $this->themeManager->expects($this->once()) + $this->themeManager->expects($this->exactly(3)) ->method('getActiveTheme') ->willReturn($this->activeTheme); $this->activeTheme->expects($this->once()) @@ -120,7 +120,7 @@ public function testDestruct() { $this->activeTheme = $this->getMockBuilder('Drupal\Core\Theme\ActiveTheme') ->disableOriginalConstructor() ->getMock(); - $this->themeManager->expects($this->once()) + $this->themeManager->expects($this->exactly(3)) ->method('getActiveTheme') ->willReturn($this->activeTheme); $this->activeTheme->expects($this->once())