Move MWDebug enabling logic to Setup.php
authorAntoine Musso <hashar@users.mediawiki.org>
Mon, 16 Jan 2012 13:44:46 +0000 (13:44 +0000)
committerAntoine Musso <hashar@users.mediawiki.org>
Mon, 16 Jan 2012 13:44:46 +0000 (13:44 +0000)
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
includes/debug/Debug.php

index fe9818a..1cf803c 100644 (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' ) ) {
index 664b4fe..b5ee0d2 100644 (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' );
        }