r23133 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r23132‎ | r23133 | r23134 >
Date:19:35, 20 June 2007
Author:brion
Status:old
Tags:
Comment:
* 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.
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/Hooks.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Hooks.php
@@ -119,6 +119,18 @@
120120 global $wgOut;
121121 $wgOut->showFatalError($retval);
122122 return false;
 123+ } elseif( $retval === null ) {
 124+ if( is_array( $callback ) ) {
 125+ if( is_object( $callback[0] ) ) {
 126+ $prettyClass = get_class( $callback[0] );
 127+ } else {
 128+ $prettyClass = strval( $callback[1] );
 129+ }
 130+ $prettyFunc = $prettyClass . '::' . strval( $callback[1] );
 131+ } else {
 132+ $prettyFunc = strval( $callback );
 133+ }
 134+ throw new MWException( "Invalid NULL return from broken hook $prettyFunc" );
123135 } else if (!$retval) {
124136 return false;
125137 }
Index: trunk/phase3/RELEASE-NOTES
@@ -92,6 +92,9 @@
9393 * (bug 9328) Use "revision-info-current" message in place of "revision-info"
9494 when viewing the current revision of a page, if available
9595 * (bug 8890) Enable wiki text for "license" message
 96+* Throw a showstopper exception when a hook function fails to return a value.
 97+ Forgetting to give a 'true' return value is a very common error which tends
 98+ to cause hard-to-track-down interactions between extensions.
9699
97100 == Bugfixes since 1.10 ==
98101

Follow-up revisions

RevisionCommit summaryAuthorDate
r23203Merged revisions 23120-23202 via svnmerge from...david09:07, 22 June 2007
r23420Fixed incorrect error message for static member functionststarling14:52, 26 June 2007
r24286pretty up the hook error message with an explanation of what it should do ins...brion15:15, 20 July 2007

Status & tagging log