From 5912473690f6499e6ab3c947cd508140c8727c49 Mon Sep 17 00:00:00 2001 From: Antoine Musso Date: Mon, 6 Feb 2012 16:42:58 +0000 Subject: [PATCH] reverts r110488 Breaks maintenance/rebuildFileCache.php with stack trace saying that FauxRequest::getRequestURL() not implemented Backtrace: #0 includes/WebRequest.php(1261): FauxRequest->notImplemented('FauxRequest::ge...') #1 includes/debug/Debug.php(266): FauxRequest->getRequestURL() #2 includes/Skin.php(561): MWDebug::getDebugHTML(Object(RequestContext)) #3 includes/SkinTemplate.php(461): Skin->generateDebugHTML() #4 includes/OutputPage.php(1982): SkinTemplate->outputPage() #5 maintenance/rebuildFileCache.php(119): OutputPage->output() #6 maintenance/doMaintenance.php(105): RebuildFileCache->execute() #7 maintenance/rebuildFileCache.php(146): require_once('/srv/trunk/main...') #8 {main} --- includes/OutputPage.php | 2 -- includes/Setup.php | 1 + includes/debug/Debug.php | 46 +++++++++++++++++++++++----------------- 3 files changed, 28 insertions(+), 21 deletions(-) diff --git a/includes/OutputPage.php b/includes/OutputPage.php index cc9118af52..6e892b4dfd 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -2456,8 +2456,6 @@ $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 00df897229..1cf803c14a 100644 --- a/includes/Setup.php +++ b/includes/Setup.php @@ -427,6 +427,7 @@ if ( $wgCommandLineMode ) { } } wfDebug( "$debug\n" ); + MWDebug::processRequest( $wgRequest ); } wfProfileOut( $fname . '-misc1' ); diff --git a/includes/debug/Debug.php b/includes/debug/Debug.php index 2f03feec9c..b8376047a5 100644 --- a/includes/debug/Debug.php +++ b/includes/debug/Debug.php @@ -31,6 +31,13 @@ class MWDebug { */ protected static $query = array(); + /** + * Request information + * + * @var array + */ + protected static $request = array(); + /** * Is the debugger enabled? * @@ -52,18 +59,7 @@ class MWDebug { */ public static function init() { self::$enabled = true; - } - - /** - * 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' ); - } + RequestContext::getMain()->getOutput()->addModules( 'mediawiki.debug' ); } /** @@ -220,6 +216,24 @@ 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 * @@ -253,7 +267,6 @@ class MWDebug { global $wgVersion, $wgRequestTime; MWDebug::log( 'MWDebug output complete' ); - $request = $context->getRequest(); $debugInfo = array( 'mwVersion' => $wgVersion, 'phpVersion' => PHP_VERSION, @@ -261,12 +274,7 @@ class MWDebug { 'log' => self::$log, 'debugLog' => self::$debug, 'queries' => self::$query, - 'request' => array( - 'method' => $_SERVER['REQUEST_METHOD'], - 'url' => $request->getRequestURL(), - 'headers' => $request->getAllHeaders(), - 'params' => $request->getValues(), - ), + 'request' => self::$request, 'memory' => $context->getLanguage()->formatSize( memory_get_usage() ), 'memoryPeak' => $context->getLanguage()->formatSize( memory_get_peak_usage() ), 'includes' => self::getFilesIncluded( $context ), -- 2.20.1