Index: trunk/phase3/includes/OutputPage.php |
— | — | @@ -2304,13 +2304,9 @@ |
2305 | 2305 | } |
2306 | 2306 | // TODO: Should this be a static function of ResourceLoader instead? |
2307 | 2307 | // TODO: Divide off modules starting with "user", and add the user parameter to them |
2308 | | - // Determine whether we're in debug mode |
2309 | | - // Order of priority is 1) request param, 2) cookie, 3) $wg setting |
2310 | | - $debug = $wgRequest->getFuzzyBool( 'debug', |
2311 | | - $wgRequest->getCookie( 'resourceLoaderModule', '', $wgResourceLoaderDebug ) ); |
2312 | 2308 | $query = array( |
2313 | 2309 | 'lang' => $wgLang->getCode(), |
2314 | | - 'debug' => $debug ? 'true' : 'false', |
| 2310 | + 'debug' => ResourceLoader::inDebugMode() ? 'true' : 'false', |
2315 | 2311 | 'skin' => $wgUser->getSkin()->getSkinName(), |
2316 | 2312 | 'only' => $only, |
2317 | 2313 | ); |
— | — | @@ -2407,7 +2403,7 @@ |
2408 | 2404 | $scripts .= Skin::makeGlobalVariablesScript( $sk->getSkinName() ) . "\n"; |
2409 | 2405 | |
2410 | 2406 | // Script and Messages "only" |
2411 | | - if ( $wgRequest->getFuzzyBool( 'debug', $wgResourceLoaderDebug ) ) { |
| 2407 | + if ( ResourceLoader::inDebugMode() ) { |
2412 | 2408 | // Scripts |
2413 | 2409 | foreach ( $this->getModuleScripts() as $name ) { |
2414 | 2410 | $scripts .= $this->makeResourceLoaderLink( $sk, $name, 'scripts' ); |
— | — | @@ -2576,7 +2572,7 @@ |
2577 | 2573 | } |
2578 | 2574 | |
2579 | 2575 | // Support individual script requests in debug mode |
2580 | | - if ( $wgRequest->getFuzzyBool( 'debug', $wgResourceLoaderDebug ) ) { |
| 2576 | + if ( ResourceLoader::inDebugMode() ) { |
2581 | 2577 | foreach ( $this->getModuleStyles() as $name ) { |
2582 | 2578 | $tags[] = $this->makeResourceLoaderLink( $sk, $name, 'styles' ); |
2583 | 2579 | } |
Index: trunk/phase3/includes/resourceloader/ResourceLoader.php |
— | — | @@ -582,4 +582,18 @@ |
583 | 583 | public static function makeConfigSetScript( array $configuration ) { |
584 | 584 | return Xml::encodeJsCall( 'mediaWiki.config.set', array( $configuration ) ); |
585 | 585 | } |
| 586 | + |
| 587 | + /** |
| 588 | + * Determine whether debug mode was requested |
| 589 | + * Order of priority is 1) request param, 2) cookie, 3) $wg setting |
| 590 | + * @return bool |
| 591 | + */ |
| 592 | + public static function inDebugMode() { |
| 593 | + global $wgRequest, $wgResourceLoaderDebug; |
| 594 | + static $retval = null; |
| 595 | + if ( !is_null( $retval ) ) |
| 596 | + return $retval; |
| 597 | + return $retval = $wgRequest->getFuzzyBool( 'debug', |
| 598 | + $wgRequest->getCookie( 'resourceLoaderDebug', '', $wgResourceLoaderDebug ) ); |
| 599 | + } |
586 | 600 | } |