From ff39c31a97e2d2f310eba49031958c7d7e56256f Mon Sep 17 00:00:00 2001 From: Antoine Musso Date: Mon, 16 Jan 2012 13:44:46 +0000 Subject: [PATCH] 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 --- includes/Setup.php | 4 +++- includes/debug/Debug.php | 17 +++++++---------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/includes/Setup.php b/includes/Setup.php index fe9818aee1..1cf803c14a 100644 --- a/includes/Setup.php +++ b/includes/Setup.php @@ -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' ) ) { diff --git a/includes/debug/Debug.php b/includes/debug/Debug.php index 664b4feabd..b5ee0d2360 100644 --- a/includes/debug/Debug.php +++ b/includes/debug/Debug.php @@ -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' ); } -- 2.20.1