Throw on #[Hook('foo_alter')]

Created on 6 September 2024, 4 months ago
Updated 8 September 2024, 4 months ago

Problem/Motivation

For a developer that is not into the implementation details, it is weird that #[Hook('foo_alter')] does not work as expected (i.e. same as #[Alter('foo')]).

Steps to reproduce

Proposed resolution

Throw on usage of #[Hook('foo_alter')]

Remaining tasks

User interface changes

API changes

Data model changes

📌 Task
Status

Postponed: needs info

Version

1.7

Component

Code

Created by

🇩🇪Germany geek-merlin Freiburg, Germany

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @geek-merlin
  • Status changed to Postponed: needs info 4 months ago
  • 🇦🇺Australia dpi Perth, Australia

    These are of course implementation details, and perhaps also class misuse of terminology in Drupal-land.

    But an alter isn't a hook. Alters are called differently to hooks.

    I have also seen in rare cases where some hook was named with a _alter suffix, but called using the hook/invoke code path. Which would in Hux' case require you to use #[Hook] attribute. Leaving to even more #dxwtf.

    Re,

    [Hook] does not work as expected [Alter]

    I think thats just something you get used to during learning about Hux. There is a clear delineation between hook and alter. Otherwise the design of Hux would just have one universal/multi-use Hook attribute.

    I think at best for this issue, I'd consider a trigger_error or something when __constructing a #[Hook] instance, looking for str_ends_with(_alter), so at least you'd be able to patch things and deal with modules which are misbehaving w MH->invoke/alter.

    Let me know your thoughts, but for now my thinking is wontfix.

  • 🇩🇪Germany geek-merlin Freiburg, Germany

    Yes, i agree.

Production build 0.71.5 2024