Move MWDebug enabling logic to Setup.php

MWDebug initialization method was made to look up for a global variable. This
patch move the logic to Setup.php so we can replicate it when doing tests.

Side effect, MWDebug is disabled by default. Users will explicitly have to
enable it by using init().

Ping r105123
This commit is contained in:
Antoine Musso 2012-01-16 13:44:46 +00:00
parent 0ef1b1d29c
commit ff39c31a97
2 changed files with 10 additions and 11 deletions

View file

@ -359,7 +359,9 @@ if ( $wgCookieSecure === 'detect' ) {
$wgCookieSecure = ( substr( $wgServer, 0, 6 ) === 'https:' );
}
MWDebug::init();
if ( $wgDebugToolbar ) {
MWDebug::init();
}
if ( !defined( 'MW_COMPILED' ) ) {
if ( !MWInit::classExists( 'AutoLoader' ) ) {

View file

@ -3,6 +3,9 @@
/**
* New debugger system that outputs a toolbar on page view
*
* By default, most methods do nothing ( self::$enabled = false ). You have
* to explicitly call MWDebug::init() to enabled them.
*
* @todo Profiler support
*/
class MWDebug {
@ -40,7 +43,7 @@ class MWDebug {
*
* @var bool
*/
protected static $enabled = true;
protected static $enabled = false;
/**
* Array of functions that have already been warned, formatted
@ -51,17 +54,11 @@ class MWDebug {
protected static $deprecationWarnings = array();
/**
* Called in Setup.php, initializes the debugger if it is enabled with
* $wgDebugToolbar
* Enabled the debugger and load resource module.
* This is called by Setup.php when $wgDebugToolbar is true.
*/
public static function init() {
global $wgDebugToolbar;
if ( !$wgDebugToolbar ) {
self::$enabled = false;
return;
}
self::$enabled = true;
RequestContext::getMain()->getOutput()->addModules( 'mediawiki.debug' );
}