From 4d9259d36d92a5cb3d51e3c97a7f9b8bd1856deb Mon Sep 17 00:00:00 2001 From: Alexandre Emsenhuber Date: Wed, 1 Feb 2012 15:48:12 +0000 Subject: [PATCH] Recommit r109062 (Only run some MWDebug code when really needed) but leaving the addition of ResourceLoader module inside the MWDebug class this time --- includes/OutputPage.php | 2 ++ includes/Setup.php | 1 - includes/debug/Debug.php | 46 +++++++++++++++++----------------------- 3 files changed, 21 insertions(+), 28 deletions(-) diff --git a/includes/OutputPage.php b/includes/OutputPage.php index 2fb574439b..c4c0bd8bbd 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -2456,6 +2456,8 @@ $templates $this->addModules( 'mediawiki.util' ); } + MWDebug::addModules( $this ); + // Add various resources if required if ( $wgUseAjax ) { $this->addModules( 'mediawiki.legacy.ajax' ); diff --git a/includes/Setup.php b/includes/Setup.php index 1cf803c14a..00df897229 100644 --- a/includes/Setup.php +++ b/includes/Setup.php @@ -427,7 +427,6 @@ if ( $wgCommandLineMode ) { } } wfDebug( "$debug\n" ); - MWDebug::processRequest( $wgRequest ); } wfProfileOut( $fname . '-misc1' ); diff --git a/includes/debug/Debug.php b/includes/debug/Debug.php index b5ee0d2360..616eb56cb1 100644 --- a/includes/debug/Debug.php +++ b/includes/debug/Debug.php @@ -31,13 +31,6 @@ class MWDebug { */ protected static $query = array(); - /** - * Request information - * - * @var array - */ - protected static $request = array(); - /** * Is the debugger enabled? * @@ -59,7 +52,18 @@ class MWDebug { */ public static function init() { self::$enabled = true; - RequestContext::getMain()->getOutput()->addModules( 'mediawiki.debug' ); + } + + /** + * Add ResourceLoader modules to the OutputPage object if debugging is + * enabled. + * + * @param $out OutputPage + */ + public static function addModules( OutputPage $out ) { + if ( self::$enabled ) { + $out->addModules( 'mediawiki.debug' ); + } } /** @@ -216,24 +220,6 @@ class MWDebug { unset( self::$query[$id]['_start'] ); } - /** - * Processes a WebRequest object - * - * @param $request WebRequest - */ - public static function processRequest( WebRequest $request ) { - if ( !self::$enabled ) { - return; - } - - self::$request = array( - 'method' => $_SERVER['REQUEST_METHOD'], - 'url' => $request->getRequestURL(), - 'headers' => $request->getAllHeaders(), - 'params' => $request->getValues(), - ); - } - /** * Returns a list of files included, along with their size * @@ -267,6 +253,7 @@ class MWDebug { global $wgVersion, $wgRequestTime; MWDebug::log( 'MWDebug output complete' ); + $request = $context->getRequest(); $debugInfo = array( 'mwVersion' => $wgVersion, 'phpVersion' => PHP_VERSION, @@ -274,7 +261,12 @@ class MWDebug { 'log' => self::$log, 'debugLog' => self::$debug, 'queries' => self::$query, - 'request' => self::$request, + 'request' => array( + 'method' => $_SERVER['REQUEST_METHOD'], + 'url' => $request->getRequestURL(), + 'headers' => $request->getAllHeaders(), + 'params' => $request->getValues(), + ), 'memory' => $context->getLanguage()->formatSize( memory_get_usage() ), 'memoryPeak' => $context->getLanguage()->formatSize( memory_get_peak_usage() ), 'includes' => self::getFilesIncluded( $context ), -- 2.20.1