r72777 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r72776‎ | r72777 | r72778 >
Date:08:03, 11 September 2010
Author:tparscal
Status:ok (Comments)
Tags:
Comment:
Added versions to statically added ResourceLoader script and style tags.
Modified paths:
  • /trunk/phase3/includes/OutputPage.php (modified) (history)
  • /trunk/phase3/includes/ResourceLoader.php (modified) (history)
  • /trunk/phase3/includes/ResourceLoaderContext.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/ResourceLoaderContext.php
@@ -26,7 +26,6 @@
2727 /* Protected Members */
2828
2929 protected $request;
30 - protected $server;
3130 protected $modules;
3231 protected $language;
3332 protected $direction;
@@ -64,7 +63,7 @@
6564 $this->skin = $wgDefaultSkin;
6665 }
6766 }
68 -
 67+
6968 public function getRequest() {
7069 return $this->request;
7170 }
@@ -114,4 +113,4 @@
115114 $this->hash : $this->hash =
116115 implode( '|', array( $this->language, $this->skin, $this->user, $this->debug, $this->only ) );
117116 }
118 -}
 117+}
\ No newline at end of file
Index: trunk/phase3/includes/OutputPage.php
@@ -2286,13 +2286,13 @@
22872287 // TODO: Divide off modules starting with "user", and add the user parameter to them
22882288 $query = array(
22892289 'lang' => $wgLang->getCode(),
2290 - 'debug' => $wgRequest->getBool( 'debug' ) && $wgRequest->getVal( 'debug' ) !== 'false',
 2290+ 'debug' => ( $wgRequest->getBool( 'debug' ) && $wgRequest->getVal( 'debug' ) == 'true' ) ? 'true' : 'false',
22912291 'skin' => $wgUser->getSkin()->getSkinName(),
22922292 'only' => $only,
22932293 );
22942294 $moduleGroups = array( null => array(), 'user' => array() );
2295 - foreach ( (array) $modules as $module ) {
2296 - $moduleGroups[strpos( $module, 'user' ) === 0 ? 'user' : null][] = $module;
 2295+ foreach ( (array) $modules as $name ) {
 2296+ $moduleGroups[strpos( $name, 'user' ) === 0 ? 'user' : null][] = $name;
22972297 }
22982298 $links = '';
22992299 foreach ( $moduleGroups as $group => $modules ) {
@@ -2301,6 +2301,16 @@
23022302 if ( $group === 'user' ) {
23032303 $query['user'] = $wgUser->getName();
23042304 }
 2305+ $context = new ResourceLoaderContext( new FauxRequest( $query ) );
 2306+ $timestamp = 0;
 2307+ foreach ( $modules as $name ) {
 2308+ if ( $module = ResourceLoader::getModule( $name ) ) {
 2309+ $timestamp = max( $timestamp, $module->getModifiedTime( $context ) );
 2310+ }
 2311+ }
 2312+ $query['version'] = wfTimestamp( TS_ISO_8601, round( $timestamp, -2 ) );
 2313+ // Make queries uniform in order
 2314+ ksort( $query );
23052315 // Automatically select style/script elements
23062316 if ( $only === 'styles' ) {
23072317 $links .= Html::linkedStyle( wfAppendQuery( $wgLoadScript, $query ) );
Index: trunk/phase3/includes/ResourceLoader.php
@@ -338,7 +338,7 @@
339339 }
340340
341341 $statuses = FormatJson::encode( $statuses );
342 - echo "mediaWiki.loader.state( $statuses );";
 342+ echo "mediaWiki.loader.state( $statuses );\n";
343343 }
344344
345345 // Register missing modules

Comments

#Comment by Happy-melon (talk | contribs)   23:01, 17 December 2010

Why is that whole ( $wgRequest->getBool( 'debug' ) && $wgRequest->getVal( 'debug' ) == 'true' ) construction needed anyway? Is there no single WebRequest method which will get the result we need? :|

#Comment by Trevor Parscal (WMF) (talk | contribs)   01:42, 18 December 2010

This should have been converted to use getFuzzyBool back when it was introduced.

Status & tagging log