*/
function wfDebug( $text, $logonly = false ) {
global $wgOut, $wgDebugLogFile, $wgDebugComments, $wgProfileOnly, $wgDebugRawPage;
- global $wgDebugLogPrefix;
+ global $wgDebugLogPrefix, $wgShowDebug;
static $recursion = 0;
static $cache = array(); // Cache of unoutputted messages
return;
}
- if ( $wgDebugComments && !$logonly ) {
+ if ( ( $wgDebugComments || $wgShowDebug ) && !$logonly ) {
$cache[] = $text;
if ( !isset( $wgOut ) ) {
if( $this->useGzip() )
$this->mFileCache .= '.gz';
- wfDebug( " fileCacheName() - {$this->mFileCache}\n" );
+ wfDebug( __METHOD__ . ": {$this->mFileCache}\n" );
}
return $this->mFileCache;
}
$cachetime = $this->fileCacheTime();
$good = $timestamp <= $cachetime && $wgCacheEpoch <= $cachetime;
- wfDebug(" isFileCacheGood() - cachetime $cachetime, touched '{$timestamp}' epoch {$wgCacheEpoch}, good $good\n");
+ wfDebug( __METHOD__ . ": cachetime $cachetime, touched '{$timestamp}' epoch {$wgCacheEpoch}, good $good\n");
return $good;
}
/* Working directory to/from output */
public function loadFromFileCache() {
global $wgOut, $wgMimeType, $wgOutputEncoding, $wgContLanguageCode;
- wfDebug(" loadFromFileCache()\n");
+ wfDebug( __METHOD__ . "()\n");
$filename = $this->fileCacheName();
// Raw pages should handle cache control on their own,
// even when using file cache. This reduces hits from clients.
return $text;
}
- wfDebug(" saveToFileCache()\n", false);
+ wfDebug( __METHOD__ . "()\n", false);
$this->checkCacheDirs();
protected function generateDebugHTML() {
global $wgShowDebug, $wgOut;
if ( $wgShowDebug ) {
- $listInternals = str_replace( "\n", "</li>\n<li>", htmlspecialchars( $wgOut->mDebugtext ) );
- return "\n<hr>\n<strong>Debug data:</strong><ul style=\"font-family:monospace;\"><li>" .
- $listInternals . "</li></ul>\n";
+ $listInternals = $this->formatDebugHTML( $wgOut->mDebugtext );
+ return "\n<hr />\n<strong>Debug data:</strong><ul style=\"font-family:monospace;\" id=\"mw-debug-html\">" .
+ $listInternals . "</ul>\n";
}
return '';
}
+ private function formatDebugHTML( $debugText ) {
+ $lines = explode( "\n", $debugText );
+ $curIdent = 0;
+ $ret = '<li>';
+ foreach( $lines as $line ) {
+ $m = array();
+ $display = ltrim( $line );
+ $ident = strlen( $line ) - strlen( $display );
+ $diff = $ident - $curIdent;
+
+ if ( $display == '' )
+ $display = "\xc2\xa0";
+
+ if ( !$ident && $diff < 0 && substr( $display, 0, 9 ) != 'Entering ' && substr( $display, 0, 8 ) != 'Exiting ' ) {
+ $ident = $curIdent;
+ $diff = 0;
+ $display = '<span style="background:yellow;">' . htmlspecialchars( $display ) . '</span>';
+ } else {
+ $display = htmlspecialchars( $display );
+ }
+
+ if ( $diff < 0 )
+ $ret .= str_repeat( "</li></ul>\n", -$diff ) . "<li>\n";
+ elseif ( $diff == 0 )
+ $ret .= "</li><li>\n";
+ else
+ $ret .= str_repeat( "<ul><li>\n", $diff );
+ $ret .= $display . "\n";
+
+ $curIdent = $ident;
+ }
+ $ret .= str_repeat( '</li></ul>', $curIdent ) . '</li>';
+ return $ret;
+ }
+
/**
* This gets called shortly before the </body> tag.
* @return String HTML to be put before </body>
global $wgDisableCounters, $wgLogo, $wgHideInterlanguageLinks;
global $wgMaxCredits, $wgShowCreditsIfMax;
global $wgPageShowWatchingUsers;
- global $wgUseTrackbacks, $wgUseSiteJs;
+ global $wgUseTrackbacks, $wgUseSiteJs, $wgDebugComments;
global $wgArticlePath, $wgScriptPath, $wgServer, $wgCanonicalNamespaceNames;
wfProfileIn( __METHOD__ );
$tpl->set( 'privacy', $this->privacyLink() );
$tpl->set( 'about', $this->aboutLink() );
- $tpl->setRef( 'debug', $out->mDebugtext );
+ if ( $wgDebugComments ) {
+ $tpl->setRef( 'debug', $out->mDebugtext );
+ } else {
+ $tpl->set( 'debug', '' );
+ }
+
$tpl->set( 'reporttime', wfReportTime() );
$tpl->set( 'sitenotice', wfGetSiteNotice() );
$tpl->set( 'bottomscripts', $this->bottomScripts() );