logger: Produce traces for all Throwables
[lhc/web/wiklou.git] / includes / debug / MWDebug.php
index e67a0b3..e877836 100644 (file)
@@ -185,7 +185,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).
@@ -349,12 +349,11 @@ class MWDebug {
         * @param string $function
         * @param bool $isMaster
         * @param float $runTime Query run time
-        * @return int ID number of the query to pass to queryTime or -1 if the
-        *  debugger is disabled
+        * @return bool True if debugger is enabled, false otherwise
         */
        public static function query( $sql, $function, $isMaster, $runTime ) {
                if ( !self::$enabled ) {
-                       return -1;
+                       return false;
                }
 
                // Replace invalid UTF-8 chars with a square UTF-8 character
@@ -389,7 +388,7 @@ class MWDebug {
                        'time' => $runTime,
                ];
 
-               return count( self::$query ) - 1;
+               return true;
        }
 
        /**
@@ -425,13 +424,14 @@ class MWDebug {
                $html = '';
 
                if ( self::$enabled ) {
-                       MWDebug::log( 'MWDebug output complete' );
+                       self::log( 'MWDebug output complete' );
                        $debugInfo = self::getDebugInfo( $context );
 
                        // Cannot use OutputPage::addJsConfigVars because those are already outputted
                        // by the time this method is called.
                        $html = ResourceLoader::makeInlineScript(
-                               ResourceLoader::makeConfigSetScript( [ 'debugInfo' => $debugInfo ] )
+                               ResourceLoader::makeConfigSetScript( [ 'debugInfo' => $debugInfo ] ),
+                               $context->getOutput()->getCSPNonce()
                        );
                }
 
@@ -495,7 +495,7 @@ class MWDebug {
                        }
                }
 
-               MWDebug::log( 'MWDebug output complete' );
+               self::log( 'MWDebug output complete' );
                $debugInfo = self::getDebugInfo( $context );
 
                ApiResult::setIndexedTagName( $debugInfo, 'debuginfo' );
@@ -517,7 +517,7 @@ class MWDebug {
                        return [];
                }
 
-               global $wgVersion, $wgRequestTime;
+               global $wgVersion;
                $request = $context->getRequest();
 
                // HHVM's reported memory usage from memory_get_peak_usage()
@@ -540,7 +540,7 @@ class MWDebug {
                        'gitRevision' => GitInfo::headSHA1(),
                        'gitBranch' => $branch,
                        'gitViewUrl' => GitInfo::headViewUrl(),
-                       'time' => microtime( true ) - $wgRequestTime,
+                       'time' => $request->getElapsedTime(),
                        'log' => self::$log,
                        'debugLog' => self::$debug,
                        'queries' => self::$query,