function wfDebug( $text, $logonly = false ) {
global $wgOut, $wgDebugLogFile, $wgDebugComments, $wgProfileOnly, $wgDebugRawPage;
global $wgDebugLogPrefix, $wgShowDebug;
- static $recursion = 0;
static $cache = array(); // Cache of unoutputted messages
$text = wfDebugTimer() . $text;
if ( ( $wgDebugComments || $wgShowDebug ) && !$logonly ) {
$cache[] = $text;
- if ( !isset( $wgOut ) ) {
- return;
- }
- if ( !StubObject::isRealObject( $wgOut ) ) {
- if ( $recursion ) {
- return;
- }
- $recursion++;
- $wgOut->_unstub();
- $recursion--;
+ if ( isset( $wgOut ) && StubObject::isRealObject( $wgOut ) ) {
+ // add the message and any cached messages to the output
+ array_map( array( $wgOut, 'debug' ), $cache );
+ $cache = array();
}
-
- // 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