From 418f0faafe1c594054ed37a0fc52650eeb29ca4e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Niklas=20Laxstr=C3=B6m?= Date: Sat, 7 Jun 2008 12:57:59 +0000 Subject: [PATCH] * Cache debug messages until $wgOut is initialised --- includes/GlobalFunctions.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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 -- 2.20.1