From: Niklas Laxström Date: Sat, 7 Jun 2008 12:57:59 +0000 (+0000) Subject: * Cache debug messages until $wgOut is initialised X-Git-Tag: 1.31.0-rc.0~47120 X-Git-Url: http://git.cyclocoop.org/%24image?a=commitdiff_plain;h=418f0faafe1c594054ed37a0fc52650eeb29ca4e;p=lhc%2Fweb%2Fwiklou.git * Cache debug messages until $wgOut is initialised --- diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index cf6a562ae5..5069212efe 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -176,12 +176,16 @@ function wfDebug( $text, $logonly = false ) { global $wgOut, $wgDebugLogFile, $wgDebugComments, $wgProfileOnly, $wgDebugRawPage; static $recursion = 0; + static $cache = array(); // Cache of unoutputted messages + # Check for raw action using $_GET not $wgRequest, since the latter might not be initialised yet if ( isset( $_GET['action'] ) && $_GET['action'] == 'raw' && !$wgDebugRawPage ) { return; } if ( $wgDebugComments && !$logonly ) { + $cache[] = $text; + if ( !isset( $wgOut ) ) { return; } @@ -193,7 +197,10 @@ function wfDebug( $text, $logonly = false ) { $wgOut->_unstub(); $recursion--; } - $wgOut->debug( $text ); + + // add the message and possible cached ones to the output + array_map( array( $wgOut, 'debug' ), $cache ); + $cache = array(); } if ( '' != $wgDebugLogFile && !$wgProfileOnly ) { # Strip unprintables; they can switch terminal modes when binary data