Verified Commit e0fa1b64 authored by godotislate's avatar godotislate
Browse files

fix: #3566514 Theme override/extend deprecation message uses the wrong extension name

By: acbramley
parent 15474081
Loading
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -133,11 +133,12 @@ protected function getLibraryDefinitions($extension) {
   * @throws \Drupal\Core\Asset\Exception\InvalidLibrariesExtendSpecificationException
   */
  protected function applyLibrariesExtend($extension, $library_name, $library_definition) {
    $libraries_extend = $this->themeManager->getActiveTheme()->getLibrariesExtend();
    $active_theme = $this->themeManager->getActiveTheme();
    $libraries_extend = $active_theme->getLibrariesExtend();
    if (!empty($libraries_extend["$extension/$library_name"])) {
      foreach ($libraries_extend["$extension/$library_name"] as $library_extend_name) {
        if (isset($library_definition['deprecated'])) {
          $extend_message = sprintf('Theme "%s" is extending a deprecated library.', $extension);
          $extend_message = sprintf('Theme "%s" is extending a deprecated library.', $active_theme->getName());
          $library_deprecation = str_replace('%library_id%', "$extension/$library_name", $library_definition['deprecated']);
          // phpcs:ignore Drupal.Semantics.FunctionTriggerError
          @trigger_error("$extend_message $library_deprecation", E_USER_DEPRECATED);
+1 −1
Original line number Diff line number Diff line
@@ -530,7 +530,7 @@ protected function applyLibrariesOverride($libraries, $extension) {
        // Process libraries overrides.
        if (isset($libraries_overrides["$extension/$library_name"])) {
          if (isset($library['deprecated'])) {
            $override_message = sprintf('Theme "%s" is overriding a deprecated library.', $extension);
            $override_message = sprintf('Theme "%s" is overriding a deprecated library.', $active_theme->getName());
            $library_deprecation = str_replace('%library_id%', "$extension/$library_name", $library['deprecated']);
            // phpcs:ignore Drupal.Semantics.FunctionTriggerError
            @trigger_error("$override_message $library_deprecation", E_USER_DEPRECATED);
+2 −2
Original line number Diff line number Diff line
@@ -261,8 +261,8 @@ public function testLibrariesExtend(): void {
  public function testDeprecatedLibrary(): void {
    $this->expectUserDeprecationMessage('Targeting theme_test/moved_from css/foo.css from test_theme_with_deprecated_libraries library_overrides is deprecated in drupal:X.0.0 and will be removed in drupal:Y.0.0. Target theme_test/moved_to css/base-remove.css instead. See https://example.com');
    $this->expectUserDeprecationMessage('Targeting theme_test/moved_from js/bar.js from test_theme_with_deprecated_libraries library_overrides is deprecated in drupal:X.0.0 and will be removed in drupal:Y.0.0. Target theme_test/moved_to js/foo.js instead. See https://example.com');
    $this->expectUserDeprecationMessage('Theme "theme_test" is overriding a deprecated library. The "theme_test/deprecated_library" asset library is deprecated in drupal:X.0.0 and is removed from drupal:Y.0.0. Use another library instead. See https://www.example.com');
    $this->expectUserDeprecationMessage('Theme "theme_test" is extending a deprecated library. The "theme_test/another_deprecated_library" asset library is deprecated in drupal:X.0.0 and is removed from drupal:Y.0.0. Use another library instead. See https://www.example.com');
    $this->expectUserDeprecationMessage('Theme "test_theme_with_deprecated_libraries" is overriding a deprecated library. The "theme_test/deprecated_library" asset library is deprecated in drupal:X.0.0 and is removed from drupal:Y.0.0. Use another library instead. See https://www.example.com');
    $this->expectUserDeprecationMessage('Theme "test_theme_with_deprecated_libraries" is extending a deprecated library. The "theme_test/another_deprecated_library" asset library is deprecated in drupal:X.0.0 and is removed from drupal:Y.0.0. Use another library instead. See https://www.example.com');
    $this->expectUserDeprecationMessage('The "theme_test/deprecated_library" asset library is deprecated in drupal:X.0.0 and is removed from drupal:Y.0.0. Use another library instead. See https://www.example.com');
    $this->expectUserDeprecationMessage('The "theme_test/another_deprecated_library" asset library is deprecated in drupal:X.0.0 and is removed from drupal:Y.0.0. Use another library instead. See https://www.example.com');
    $this->activateTheme('test_theme_with_deprecated_libraries');
+2 −2
Original line number Diff line number Diff line
@@ -226,14 +226,14 @@ public function testLibrariesExtend(): void {
   */
  #[IgnoreDeprecations]
  public function testLibrariesExtendDeprecated(): void {
    $this->expectUserDeprecationMessage('Theme "test" is extending a deprecated library. The "test/test_4" asset library is deprecated in drupal:X.0.0 and is removed from drupal:Y.0.0. Use the test_3 library instead. See https://www.example.com');
    $this->expectUserDeprecationMessage('Theme "kitten_theme" is extending a deprecated library. The "test/test_4" asset library is deprecated in drupal:X.0.0 and is removed from drupal:Y.0.0. Use the test_3 library instead. See https://www.example.com');
    $this->activeTheme = $this->getMockBuilder(ActiveTheme::class)
      ->disableOriginalConstructor()
      ->getMock();
    $this->themeManager->expects($this->any())
      ->method('getActiveTheme')
      ->willReturn($this->activeTheme);
    $this->activeTheme->expects($this->once())
    $this->activeTheme->expects($this->atLeastOnce())
      ->method('getName')
      ->willReturn('kitten_theme');
    $this->activeTheme->expects($this->atLeastOnce())
+4 −1
Original line number Diff line number Diff line
@@ -684,12 +684,15 @@ public function testLibraryOverride(): void {
   */
  #[IgnoreDeprecations]
  public function testLibraryOverrideDeprecated(): void {
    $this->expectUserDeprecationMessage('Theme "deprecated" is overriding a deprecated library. The "deprecated/deprecated" asset library is deprecated in drupal:X.0.0 and is removed from drupal:Y.0.0. Use another library instead. See https://www.example.com');
    $this->expectUserDeprecationMessage('Theme "test_theme" is overriding a deprecated library. The "deprecated/deprecated" asset library is deprecated in drupal:X.0.0 and is removed from drupal:Y.0.0. Use another library instead. See https://www.example.com');
    $mock_theme_path = 'mocked_themes/kittens';
    $this->themeManager = $this->createMock(ThemeManagerInterface::class);
    $this->activeTheme = $this->getMockBuilder(ActiveTheme::class)
      ->disableOriginalConstructor()
      ->getMock();
    $this->activeTheme->expects($this->atLeastOnce())
      ->method('getName')
      ->willReturn('test_theme');
    $this->activeTheme->expects($this->atLeastOnce())
      ->method('getLibrariesOverride')
      ->willReturn([