From: Brion Vibber Date: Wed, 20 Jun 2007 19:35:17 +0000 (+0000) Subject: * Throw a showstopper exception when a hook function fails to return a value. X-Git-Tag: 1.31.0-rc.0~52482 X-Git-Url: http://git.cyclocoop.org/%28?a=commitdiff_plain;h=4e83003145c7c7dc7e1375d194f3475984d5db55;p=lhc%2Fweb%2Fwiklou.git * 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. --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index caba589435..eea6e4afbe 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -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 == diff --git a/includes/Hooks.php b/includes/Hooks.php index b428b08d7c..618fb22aba 100644 --- a/includes/Hooks.php +++ b/includes/Hooks.php @@ -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; }