Drupal\Core\Theme\Registry::$registry is an array with this format:

$this->registry[$theme_name][$theme_hook] = $theme_registry_entry

However, Drupal\Core\Theme\Registry::getBaseHook() treats this array as if the array keys were hook names, not theme names.

      if (isset($this->registry[$base_hook]['exists'])) {
        break;
      }

As far as I know (grep), the method is never called anywhere in core.
If it is called in contrib, it won't work correctly.

And in fact, to get the base hook, one would rather want to use the runtime theme registry (Drupal\Core\Utility\ThemeRegistry), not Drupal\Core\Theme\Registry.

Proposed change

Perhaps the best option is to remove this method?

Issue fork drupal-2957444

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

donquixote created an issue. See original summary.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

smustgrave’s picture

This came up as a daily BSI

This still appears to be valid, can't find anywhere getBaseHook is actually called in core.

We should deprecate it properly.

Also tagged for summary update to use standard template.

sujal kshatri’s picture

Hey , will this work?

Adding a deprecation docblock like :-

@deprecated in drupal:11.0.0 and will be removed in drupal:12.0.0. This method is not used by core and does not work correctly with the internal structure of the theme registry. Use the runtime theme registry (Drupal\Core\Utility\ThemeRegistry) instead.

@see https://www.drupal.org/node/2957444

And inside the method, this as the first line:

public function getBaseHook($hook) {
  @trigger_error(__METHOD__ . '() is deprecated and will be removed in Drupal 12.0.0. Use the runtime theme registry (Drupal\Core\Utility\ThemeRegistry) instead.', E_USER_DEPRECATED);

  // existing method remians as it is
}

smustgrave’s picture

Close but in this case there would be no replacement because it's not used. There are several examples in core with the correct verbage. A change record will have to be written for the link.

sujal kshatri’s picture

Thanks, Okay then I'll look at some examples and also write a change record

sujal kshatri’s picture

sujal kshatri’s picture

I looked at some of the examples and came up with this.
Final would look something like this:-


@deprecated in drupal:11.0.0 and is removed from drupal:12.0.0.
   This method is not used by core and does not work correctly.
   There is no replacement.

 @see https://www.drupal.org/node/3567793

And inside the method, this as the first line:


@trigger_error(__METHOD__ . '() is deprecated in drupal:11.0.0 and is removed from drupal:12.0.0. This method is not used by core and does not work correctly. There is no replacement. See https://www.drupal.org/node/3567793', E_USER_DEPRECATED);

My doubt is wether i should write @deprecated in drupal:11.0.0 and is removed from drupal:12.0.0. or @deprecated in drupal:11.0.0 and will be removed from drupal:12.0.0. ?

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.

sujal kshatri’s picture

Status: Active » Needs review
smustgrave’s picture

Status: Needs review » Needs work

I don't see an MR but that message is incorrect too. Check other deprecations in core examples. This would be deprecated in 11.4 and removed in 12

sujal kshatri’s picture

I wanted to confirm whether that message was correct or not before making the MR, thanks for the feedback i'll look at other core deprecations and make changes to mine

sujal kshatri’s picture

Status: Needs work » Needs review
nicxvan’s picture

A couple suggestions on the MR.

Will be is correct.

I think removal in 12 is fine since it's not used.
I'll do a quick search too.

Edit, I couldn't find any instances in contrib.

dcam’s picture

Status: Needs review » Needs work
Issue tags: -Needs change record

This issue was tagged for needing an update to the issue summary. The standard issue summary template should be applied. All of the standard headings should be added, even if they have no content or "N/A" under them.

For that reason and @nicxvan's suggestions I'm setting the issue status to Needs Work.

quietone’s picture

The change record for this issue was published. Since this hasn't been committed I have returned it to a draft.

nakaza sora made their first commit to this issue’s fork.

dany.almeida.kairouz’s picture

Issue tags: +Drupalcon Chicago 2026

The Drupal Contribution Mentoring team is triaging issues for DrupalCon Chicago 2026, and we are reserving this issue for Mentored Contribution during the event.

After Thursday 26th March 2026 + 1 DAY (13:00 UTC), this issue returns to being open to all. Thanks!

mradcliffe’s picture

Issue tags: -Drupalcon Chicago 2026 +Chicago2026

Fixing the tag.