Add ability to detect deprecated hooks

Created on 26 May 2020, about 4 years ago
Updated 26 October 2023, 8 months ago

I've been checking some of my code for D9 compability, and have struggled to find a tool that will flag up the use of deprecated hooks - I was specifically looking at these Search API hooks which are marked as deprecated, but there must be plenty of others that currently aren't detectable automatically: https://git.drupalcode.org/project/search_api/-/blob/8.x-1.x/search_api..... OO code and core hooks seem well covered, but I couldn't configure anything to flag up contrib despite it being annotated with @deprecated.

I raised this as an issue in #d9readiness during the porting weekend, and it was suggested this would be the most relevant place to raise an issue. Let me know if you need any more details. Thanks.

โœจ Feature request
Status

Active

Version

2.0

Component

Code

Created by

๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom ben.kyriakou

Live updates comments and jobs are added and updated live.
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.

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom millnut

    We've just hit this doing an upgrade from Drupal 9.5 to Drupal 10 where deprecated hooks are not flagged in upgrade status.

    Is there any recent update on progress with getting upgrade status to detected deprecated hooks?

    Failing that is there a way to get a full list of all hooks deprecated in 9.x and removed in 10?

  • ๐Ÿ‡บ๐Ÿ‡พUruguay fanton Uruguay

    In Drupal 9, there are only 4 deprecated hooks (you can verify this here):

    - hook_field_widget_form_alter
    - hook_field_widget_multivalue_form_alter
    - hook_field_widget_multivalue_WIDGET_TYPE_form_alter
    - hook_field_widget_WIDGET_TYPE_form_alter

    While it would be great to have automatic detection of deprecated hooks, since this feature is not available for now, it should be mentioned in the Upgrade Status feature list so that users are aware that they need to verify it manually.

  • ๐Ÿ‡ญ๐Ÿ‡บHungary Gรกbor Hojtsy Hungary

    See https://github.com/mglaman/phpstan-drupal/issues/126 for discussion on doing this in phpstan-drupal. I relayed your info @fanton to there. While we could write one-off code for these in Upgrade Status, it would be more universal to cover it in phpstan-drupal.

  • Status changed to Active 9 months ago
  • ๐Ÿ‡ญ๐Ÿ‡บHungary Gรกbor Hojtsy Hungary
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States jnicola

    Just ran into this issue, thankfully we have really good test coverage that caught the issue.

    Specifically our issue was with hook_field_widget_WIDGET_TYPE_form_alter

    Google for "Drupal 10 deprecated hooks" does not yield any useful information on this topic either.

Production build 0.69.0 2024