Invoke hooks via the 'module_handler' service

Created on 12 November 2022, about 2 years ago
Updated 3 February 2024, 10 months ago

Problem/Motivation

All hooks have to invoke via the 'module_handler' service. If it isn't call via the call_user_func function.
I ran into a problem when hook_cron invisible for the Ultimate Cron.

Steps to reproduce

  1. Install the Hux module.
  2. Add hook_cron via attribute (like write in README of the Hux module). Make sure that this issue was merged or just apply patch.
  3. Click Discover Job button
  4. Try to run this cron.

Proposed resolution

We have to check if it hook and invoke via the 'module_handler' service.

🐛 Bug report
Status

Needs work

Version

2.0

Component

Code

Created by

🇵🇱Poland miroslav-lee Krakow

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.

  • 🇨🇭Switzerland berdir Switzerland

    Related issues: hook_event_dispatcher compatability Active and 📌 Support CronSubscribers Active (and the related core issue).

    Interesting solution but it's trying to be a little bit too generic I think. Whether or not something is/has certain hook is just a naming convention, with that logic, any module-prefixed callback is going to be recognized as a hook.

    Instead, we should do this only if it the cron hook. Meaning, isCallbackHook() should just check $this->getHookName() === 'cron', at this point we can of need to expect that it exists.

    Hopefully, the long-term solution is the core issue that I created to make cron tasks/jobs their own thing that can be discovered and not hooks. Feedback/reviews there would definitely be welcome.

Production build 0.71.5 2024