Deprecate ModuleHandlerInterface::*Deprecated() in favor of hook metadata

Created on 20 September 2018, over 6 years ago
Updated 5 May 2025, 7 days ago

Problem/Motivation

#2866779: Add a way to trigger_error() for deprecated hooks β†’ added ways to mark hooks deprecated by introducing new API methods. This means we needed one new API method for every method hooks can be invoked, adding three new methods for one small purpose, as well as putting the deprecation burden not on the hook owner, but the owner of every single invocation of deprecated hooks, and while we tend to wrap hook invocations in their own API methods, invoking hooks without API wrappers used to be common practice for a long time.

Proposed resolution

We can deprecate these three ::*Deprecated() methods and put the burden of deprecation solely with hook owners by marking hooks deprecated in hook_hook_info() implementations:
Before Drupal 8.7:

\Drupal::moduleHandler()->invokeDeprecated('foo_bar');

Drupal 8.7:

function foo_hook_info() {
return [
  'foo_bar' => [
    'deprecated' => 'hook_foobar() has been deprecated since Drupal 8.7. Use hook_foo_baz() instead. See https://drupal.org/node/foo_bar',
  ],
]
}

ModuleHandler::getImplementations() will trigger errors for any implementations of deprecated hooks.

Remaining tasks

  • Deprecate the change record β†’ for the original change and document this new deprecation flag.
  • Convert all usages of the three deprecated methods in Drupal core.

User interface changes

None.

API changes

ModuleHandlerInterface::*Deprecated() will become deprecated.

Data model changes

One optional addition to hook_hook_info()'s return value.

πŸ“Œ Task
Status

Needs work

Version

11.0 πŸ”₯

Component

extension system

Created by

πŸ‡¬πŸ‡§United Kingdom Xano Southampton

Live updates comments and jobs are added and updated live.
  • Needs change record

    A change record needs to be drafted before an issue is committed. Note: Change records used to be called change notifications.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024