From: Tim Starling Date: Sun, 24 Sep 2006 06:04:58 +0000 (+0000) Subject: Allow hooks to be static member functions X-Git-Tag: 1.31.0-rc.0~55735 X-Git-Url: http://git.cyclocoop.org//%27%40script%40/%27?a=commitdiff_plain;h=d4efe7fa7b85b26881fbf7357caa2a2210f836b9;p=lhc%2Fweb%2Fwiklou.git Allow hooks to be static member functions --- diff --git a/includes/Hooks.php b/includes/Hooks.php index c00fbc1447..575a28c54c 100644 --- a/includes/Hooks.php +++ b/includes/Hooks.php @@ -101,18 +101,18 @@ function wfRunHooks($event, $args = null) { $hook_args = $args; } - if ( isset( $object ) ) { $func = get_class( $object ) . '::' . $method; + $callback = array( $object, $method ); + } elseif ( false !== ( $pos = strpos( '::', $func ) ) ) { + $callback = array( substr( $func, 0, $pos ), substr( $func, $pos + 2 ) ); + } else { + $callback = $func; } /* Call the hook. */ wfProfileIn( $func ); - if( isset( $object ) ) { - $retval = call_user_func_array(array($object, $method), $hook_args); - } else { - $retval = call_user_func_array($func, $hook_args); - } + $retval = call_user_func_array( $callback, $hook_args ); wfProfileOut( $func ); /* String return is an error; false return means stop processing. */