hook_*_alter some times called too early

Created on 4 December 2014, over 10 years ago
Updated 22 July 2023, over 1 year ago

I just experienced that for some reason the form_alter hooks of simplify got called before some other module altered the form.
Results in a non-function simplify form_alter since the altering got overwritten aftewards...

If someone else experience such an issue read about hook_module_implements_alter or the discussion about that hook in #692950: Use hook_module_implements_alter to allow modules to alter the weight of hooks in module_implements

My quick & dirty implementation looks like this:

/**
 * Implements hook_module_implements_alter()
 */
function simplify_module_implements_alter(&$implementations, $hook) {
  $module_name = "simplify";
  // our hooks need to get called after others e.g. entity_translation needs to run before our implementation
  // changes here NEED a cache clear since it writes in the system table cache
  if ($hook == 'form_alter' && isset($implementations[$module_name])) {
    $group = $implementations[$module_name];
    unset($implementations[$module_name]);
    $implementations[$module_name] = $group;
  }
}

...which might be too rough for upstream :-)

🐛 Bug report
Status

Closed: outdated

Version

3.2

Component

Code

Created by

🇦🇹Austria guedressel

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.

  • 🇫🇷France Dom.

    Version 7.x is no more really supported. Just provided as is until end-of-life.
    Feel free to reopen and update if there are reason we should still invest work on this.

Production build 0.71.5 2024