X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Fdebug%2FMWDebug.php;h=057d8fa1a0cfabe526bbeca49c709ed1ff1c96c8;hp=ae7f948f29074931503a26c416c27373518fb668;hb=88e3a888cc6823f11df79ac53eb963a7e4d2871a;hpb=d8d274aa3581000c2dc1b6c2fae823caff6f62d0 diff --git a/includes/debug/MWDebug.php b/includes/debug/MWDebug.php index ae7f948f29..057d8fa1a0 100644 --- a/includes/debug/MWDebug.php +++ b/includes/debug/MWDebug.php @@ -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). @@ -347,11 +371,11 @@ class MWDebug { * @since 1.19 * @param string $sql * @param string $function - * @param bool $isMaster * @param float $runTime Query run time + * @param string $dbhost * @return bool True if debugger is enabled, false otherwise */ - public static function query( $sql, $function, $isMaster, $runTime ) { + public static function query( $sql, $function, $runTime, $dbhost ) { if ( !self::$enabled ) { return false; } @@ -382,9 +406,8 @@ class MWDebug { $sql = UtfNormal\Validator::cleanUp( $sql ); self::$query[] = [ - 'sql' => $sql, + 'sql' => "$dbhost: $sql", 'function' => $function, - 'master' => (bool)$isMaster, 'time' => $runTime, ];