Added wfAbruptExit() function, to replace exit() calls with.
authorMr. E23 <e23@users.mediawiki.org>
Wed, 10 Dec 2003 14:58:17 +0000 (14:58 +0000)
committerMr. E23 <e23@users.mediawiki.org>
Wed, 10 Dec 2003 14:58:17 +0000 (14:58 +0000)
includes/GlobalFunctions.php

index 40effcc..f0641a1 100644 (file)
@@ -339,7 +339,7 @@ function wfSpecialPage()
 
        $par = NULL;
        list($t, $par) = split( "/", $wgTitle->getDBkey(), 2 );
-       
+
        if ( array_key_exists( $t, $validSP ) ||
          ( $wgUser->isSysop() && array_key_exists( $t, $sysopSP ) ) ||
          ( $wgUser->isDeveloper() && array_key_exists( $t, $devSP ) ) ) {
@@ -373,6 +373,24 @@ function wfGo( $s )
        $se->goResult();
 }
 
+/* private */ $wgAbruptExitCalled = false;
+
+# Just like exit() but makes a note of it.
+function wfAbruptExit(){
+       // Safety to avoid infinite recursion in case of (unlikely) bugs somewhere
+       global $wgAbruptExitCalled;
+       if ( $wgAbruptExitCalled ){
+               exit();
+       }
+       $wgAbruptExitCalled = true;
+
+       $bt = debug_backtrace();
+       $file = $bt[0]["file"];
+       $line = $bt[0]["line"];
+       wfDebug("WARNING: Abrupt exit in $file at line $line\n");
+       exit();
+}
+
 function wfNumberOfArticles()
 {
        global $wgNumberOfArticles;