Allow hooks to be static member functions
authorTim Starling <tstarling@users.mediawiki.org>
Sun, 24 Sep 2006 06:04:58 +0000 (06:04 +0000)
committerTim Starling <tstarling@users.mediawiki.org>
Sun, 24 Sep 2006 06:04:58 +0000 (06:04 +0000)
includes/Hooks.php

index c00fbc1..575a28c 100644 (file)
@@ -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. */