diff options
author | Dries Buytaert <dries@buytaert.net> | 2005-03-01 20:23:35 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2005-03-01 20:23:35 +0000 |
commit | 456fd7cc85d39b5905b37ba27b6fe588cc4432fe (patch) | |
tree | f4ee32318800b9806afe131b789622b4b35446b6 /includes/module.inc | |
parent | 84268b3a34bf5bbb09de13e09048480b527ff958 (diff) | |
download | brdo-456fd7cc85d39b5905b37ba27b6fe588cc4432fe.tar.gz brdo-456fd7cc85d39b5905b37ba27b6fe588cc4432fe.tar.bz2 |
- Patch #17770 by chx: fixed module_invoke() and module_invoke_all() not to use NULL defaults (bugfix) + removed the limitation on the number of paramaters that can be used.
Diffstat (limited to 'includes/module.inc')
-rw-r--r-- | includes/module.inc | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/includes/module.inc b/includes/module.inc index b2b1354a7..6356fb137 100644 --- a/includes/module.inc +++ b/includes/module.inc @@ -172,13 +172,15 @@ function module_implements($hook) { * @return * The return value of the hook implementation. */ -function module_invoke($module, $hook, $a1 = NULL, $a2 = NULL, $a3 = NULL, $a4 = NULL) { +function module_invoke() { + $args = func_get_args(); + $module = array_shift($args); + $hook = array_shift($args); $function = $module .'_'. $hook; - if (function_exists($function)) { - return $function($a1, $a2, $a3, $a4); + if (module_hook($module, $hook)) { + return call_user_func_array($function, $args); } } - /** * Invoke a hook in all enabled modules that implement it. * @@ -190,10 +192,13 @@ function module_invoke($module, $hook, $a1 = NULL, $a2 = NULL, $a3 = NULL, $a4 = * An array of return values of the hook implementations. If modules return * arrays from their implementations, those are merged into one array. */ -function module_invoke_all($hook, $a1 = NULL, $a2 = NULL, $a3 = NULL, $a4 = NULL) { +function module_invoke_all() { + $args = func_get_args(); + $hook = array_shift($args); $return = array(); - foreach (module_list() as $module) { - $result = module_invoke($module, $hook, $a1, $a2, $a3, $a4); + foreach (module_implements($hook) as $module) { + $function = $module .'_'. $hook; + $result = call_user_func_array($function, $args); if (is_array($result)) { $return = array_merge($return, $result); } |