Merge "Fix use of GenderCache in ApiPageSet::processTitlesArray"
[lhc/web/wiklou.git] / includes / debug / MWDebug.php
index ae7f948..6bcb0e6 100644 (file)
@@ -67,6 +67,30 @@ class MWDebug {
         */
        protected static $deprecationWarnings = [];
 
+       /**
+        * @internal For use by Setup.php only.
+        */
+       public static function setup() {
+               global $wgDebugToolbar,
+                       $wgUseCdn, $wgUseFileCache, $wgCommandLineMode;
+
+               if (
+                       // Easy to forget to falsify $wgDebugToolbar for static caches.
+                       // If file cache or CDN cache is on, just disable this (DWIMD).
+                       $wgUseCdn ||
+                       $wgUseFileCache ||
+                       // Keep MWDebug off on CLI. This prevents MWDebug from eating up
+                       // all the memory for logging SQL queries in maintenance scripts.
+                       $wgCommandLineMode
+               ) {
+                       return;
+               }
+
+               if ( $wgDebugToolbar ) {
+                       self::init();
+               }
+       }
+
        /**
         * Enabled the debugger and load resource module.
         * This is called by Setup.php when $wgDebugToolbar is true.
@@ -185,7 +209,7 @@ class MWDebug {
         * @param string $function Function that is deprecated.
         * @param string|bool $version Version in which the function was deprecated.
         * @param string|bool $component Component to which the function belongs.
-        *    If false, it is assumbed the function is in MediaWiki core.
+        *    If false, it is assumed the function is in MediaWiki core.
         * @param int $callerOffset How far up the callstack is the original
         *    caller. 2 = function that called the function that called
         *    MWDebug::deprecated() (Added in 1.20).