diff options
author | Dries <dries@buytaert.net> | 2011-11-21 22:18:43 -0500 |
---|---|---|
committer | Dries <dries@buytaert.net> | 2011-11-21 22:18:43 -0500 |
commit | b96a83b4a9a0d9fb77a4891592ea0c0a9a75ce60 (patch) | |
tree | 37afa4657a564af02e095126ecf8017a761f882c /includes | |
parent | d8b517295c4159e5b3aa40ac5d0931c6ce491866 (diff) | |
download | brdo-b96a83b4a9a0d9fb77a4891592ea0c0a9a75ce60.tar.gz brdo-b96a83b4a9a0d9fb77a4891592ea0c0a9a75ce60.tar.bz2 |
- Patch #765860 by effulgentsia, dww, dereine, mikey_p, xjm, sun, sven.lauer: drupal_alter() fails to order modules correctly in some cases.
Diffstat (limited to 'includes')
-rw-r--r-- | includes/module.inc | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/includes/module.inc b/includes/module.inc index 66c77f577..3a019f26d 100644 --- a/includes/module.inc +++ b/includes/module.inc @@ -952,10 +952,24 @@ function drupal_alter($type, &$data, &$context1 = NULL, &$context2 = NULL) { } // If any modules implement one of the extra hooks that do not implement // the primary hook, we need to add them to the $modules array in their - // appropriate order. + // appropriate order. module_implements() can only return ordered + // implementations of a single hook. To get the ordered implementations + // of multiple hooks, we mimic the module_implements() logic of first + // ordering by module_list(), and then calling + // drupal_alter('module_implements'). if (array_diff($extra_modules, $modules)) { - // Order the modules by the order returned by module_list(). + // Merge the arrays and order by module_list(). $modules = array_intersect(module_list(), array_merge($modules, $extra_modules)); + // Since module_implements() already took care of loading the necessary + // include files, we can safely pass FALSE for the array values. + $implementations = array_fill_keys($modules, FALSE); + // Let modules adjust the order solely based on the primary hook. This + // ensures the same module order regardless of whether this if block + // runs. Calling drupal_alter() recursively in this way does not result + // in an infinite loop, because this call is for a single $type, so we + // won't end up in this code block again. + drupal_alter('module_implements', $implementations, $hook); + $modules = array_keys($implementations); } foreach ($modules as $module) { // Since $modules is a merged array, for any given module, we do not |