* Throw a showstopper exception when a hook function fails to return a value.
authorBrion Vibber <brion@users.mediawiki.org>
Wed, 20 Jun 2007 19:35:17 +0000 (19:35 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Wed, 20 Jun 2007 19:35:17 +0000 (19:35 +0000)
  Forgetting to give a 'true' return value is a very common error which tends
  to cause hard-to-track-down interactions between extensions.

RELEASE-NOTES
includes/Hooks.php

index caba589..eea6e4a 100644 (file)
@@ -92,6 +92,9 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * (bug 9328) Use "revision-info-current" message in place of "revision-info"
   when viewing the current revision of a page, if available
 * (bug 8890) Enable wiki text for "license" message
+* Throw a showstopper exception when a hook function fails to return a value.
+  Forgetting to give a 'true' return value is a very common error which tends
+  to cause hard-to-track-down interactions between extensions.
 
 == Bugfixes since 1.10 ==
 
index b428b08..618fb22 100644 (file)
@@ -119,6 +119,18 @@ function wfRunHooks($event, $args = null) {
                        global $wgOut;
                        $wgOut->showFatalError($retval);
                        return false;
+               } elseif( $retval === null ) {
+                       if( is_array( $callback ) ) {
+                               if( is_object( $callback[0] ) ) {
+                                       $prettyClass = get_class( $callback[0] );
+                               } else {
+                                       $prettyClass = strval( $callback[1] );
+                               }
+                               $prettyFunc = $prettyClass . '::' . strval( $callback[1] );
+                       } else {
+                               $prettyFunc = strval( $callback );
+                       }
+                       throw new MWException( "Invalid NULL return from broken hook $prettyFunc" );
                } else if (!$retval) {
                        return false;
                }