From 00e7d8232b115047a60a2dd16369be174bc7417e Mon Sep 17 00:00:00 2001 From: Roan Kattouw Date: Fri, 5 Nov 2010 20:36:13 +0000 Subject: [PATCH] Followup r75825: per bug 25610 comment #3, check for debug mode in all other places too. --- includes/OutputPage.php | 10 +++------- includes/resourceloader/ResourceLoader.php | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/includes/OutputPage.php b/includes/OutputPage.php index 6fbd5886ff..e65450cb28 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -2304,13 +2304,9 @@ class OutputPage { } // TODO: Should this be a static function of ResourceLoader instead? // TODO: Divide off modules starting with "user", and add the user parameter to them - // Determine whether we're in debug mode - // Order of priority is 1) request param, 2) cookie, 3) $wg setting - $debug = $wgRequest->getFuzzyBool( 'debug', - $wgRequest->getCookie( 'resourceLoaderModule', '', $wgResourceLoaderDebug ) ); $query = array( 'lang' => $wgLang->getCode(), - 'debug' => $debug ? 'true' : 'false', + 'debug' => ResourceLoader::inDebugMode() ? 'true' : 'false', 'skin' => $wgUser->getSkin()->getSkinName(), 'only' => $only, ); @@ -2407,7 +2403,7 @@ class OutputPage { $scripts .= Skin::makeGlobalVariablesScript( $sk->getSkinName() ) . "\n"; // Script and Messages "only" - if ( $wgRequest->getFuzzyBool( 'debug', $wgResourceLoaderDebug ) ) { + if ( ResourceLoader::inDebugMode() ) { // Scripts foreach ( $this->getModuleScripts() as $name ) { $scripts .= $this->makeResourceLoaderLink( $sk, $name, 'scripts' ); @@ -2576,7 +2572,7 @@ class OutputPage { } // Support individual script requests in debug mode - if ( $wgRequest->getFuzzyBool( 'debug', $wgResourceLoaderDebug ) ) { + if ( ResourceLoader::inDebugMode() ) { foreach ( $this->getModuleStyles() as $name ) { $tags[] = $this->makeResourceLoaderLink( $sk, $name, 'styles' ); } diff --git a/includes/resourceloader/ResourceLoader.php b/includes/resourceloader/ResourceLoader.php index 770c62868e..ea1173682a 100644 --- a/includes/resourceloader/ResourceLoader.php +++ b/includes/resourceloader/ResourceLoader.php @@ -582,4 +582,18 @@ class ResourceLoader { public static function makeConfigSetScript( array $configuration ) { return Xml::encodeJsCall( 'mediaWiki.config.set', array( $configuration ) ); } + + /** + * Determine whether debug mode was requested + * Order of priority is 1) request param, 2) cookie, 3) $wg setting + * @return bool + */ + public static function inDebugMode() { + global $wgRequest, $wgResourceLoaderDebug; + static $retval = null; + if ( !is_null( $retval ) ) + return $retval; + return $retval = $wgRequest->getFuzzyBool( 'debug', + $wgRequest->getCookie( 'resourceLoaderDebug', '', $wgResourceLoaderDebug ) ); + } } -- 2.20.1