From ea5c70a473e67fbdf7eea53421d2ae180e301dfd Mon Sep 17 00:00:00 2001 From: "Mr. E23" Date: Wed, 10 Dec 2003 14:58:17 +0000 Subject: [PATCH] Added wfAbruptExit() function, to replace exit() calls with. --- includes/GlobalFunctions.php | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 40effcc321..f0641a1add 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -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; -- 2.20.1