Merge "Improved readability of MediaWikiParserTest::suite code"
[lhc/web/wiklou.git] / includes / Hooks.php
index 8cc7ace..16fee41 100644 (file)
@@ -66,7 +66,7 @@ class Hooks {
         * @param $callback Mixed: callback function to attach
         */
        public static function register( $name, $callback ) {
-               if( !isset( self::$handlers[$name] ) ) {
+               if ( !isset( self::$handlers[$name] ) ) {
                        self::$handlers[$name] = array();
                }
 
@@ -168,6 +168,7 @@ class Hooks {
                         */
                        if ( is_array( $hook ) ) {
                                if ( count( $hook ) < 1 ) {
+                                       wfProfileOut( 'hook: ' . $event );
                                        throw new MWException( 'Empty array in hooks for ' . $event . "\n" );
                                } elseif ( is_object( $hook[0] ) ) {
                                        $object = $hook[0];
@@ -190,11 +191,12 @@ class Hooks {
                                        }
                                } elseif ( is_string( $hook[0] ) ) {
                                        $func = $hook[0];
-                                       if ( count( $hook ) > 1) {
+                                       if ( count( $hook ) > 1 ) {
                                                $data = $hook[1];
                                                $have_data = true;
                                        }
                                } else {
+                                       wfProfileOut( 'hook: ' . $event );
                                        throw new MWException( 'Unknown datatype in hooks for ' . $event . "\n" );
                                }
                        } elseif ( is_string( $hook ) ) { # functions look like strings, too
@@ -207,6 +209,7 @@ class Hooks {
                                        $method = "on" . $event;
                                }
                        } else {
+                               wfProfileOut( 'hook: ' . $event );
                                throw new MWException( 'Unknown datatype in hooks for ' . $event . "\n" );
                        }
 
@@ -262,11 +265,11 @@ class Hooks {
                        /* String return is an error; false return means stop processing. */
                        if ( is_string( $retval ) ) {
                                throw new FatalError( $retval );
-                       } elseif( $retval === null ) {
+                       } elseif ( $retval === null ) {
                                if ( $closure ) {
                                        $prettyFunc = "$event closure";
-                               } elseif( is_array( $callback ) ) {
-                                       if( is_object( $callback[0] ) ) {
+                               } elseif ( is_array( $callback ) ) {
+                                       if ( is_object( $callback[0] ) ) {
                                                $prettyClass = get_class( $callback[0] );
                                        } else {
                                                $prettyClass = strval( $callback[0] );
@@ -276,11 +279,13 @@ class Hooks {
                                        $prettyFunc = strval( $callback );
                                }
                                if ( $badhookmsg ) {
+                                       wfProfileOut( 'hook: ' . $event );
                                        throw new MWException(
                                                'Detected bug in an extension! ' .
                                                "Hook $prettyFunc has invalid call signature; " . $badhookmsg
                                        );
                                } else {
+                                       wfProfileOut( 'hook: ' . $event );
                                        throw new MWException(
                                                'Detected bug in an extension! ' .
                                                "Hook $prettyFunc failed to return a value; " .