r85677 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r85676‎ | r85677 | r85678 >
Date:17:43, 8 April 2011
Author:dale
Status:deferred (Comments)
Tags:
Comment:
sync with mediaWiki trunk ResourceLodaer updates ( r85672 )
added README that describes how resources are synced with trunk
Modified paths:
  • /branches/MwEmbedStandAloneRL1_17/MwEmbedStandAlone/includes/resourceloader/README (added) (history)
  • /branches/MwEmbedStandAloneRL1_17/MwEmbedStandAlone/includes/resourceloader/ResourceLoader.php (modified) (history)
  • /branches/MwEmbedStandAloneRL1_17/MwEmbedStandAlone/includes/resourceloader/ResourceLoaderContext.php (modified) (history)
  • /branches/MwEmbedStandAloneRL1_17/MwEmbedStandAlone/includes/resourceloader/ResourceLoaderFileModule.php (modified) (history)
  • /branches/MwEmbedStandAloneRL1_17/MwEmbedStandAlone/includes/resourceloader/ResourceLoaderModule.php (modified) (history)
  • /branches/MwEmbedStandAloneRL1_17/MwEmbedStandAlone/includes/resourceloader/ResourceLoaderStartUpModule.php (modified) (history)

Diff [purge]

Index: branches/MwEmbedStandAloneRL1_17/MwEmbedStandAlone/includes/resourceloader/ResourceLoader.php
@@ -29,6 +29,7 @@
3030 class ResourceLoader {
3131
3232 /* Protected Static Members */
 33+ protected static $filterCacheVersion = 4;
3334
3435 /** Array: List of module name/ResourceLoaderModule object pairs */
3536 protected $modules = array();
@@ -62,7 +63,7 @@
6364 // Get file dependency information
6465 $res = $dbr->select( 'module_deps', array( 'md_module', 'md_deps' ), array(
6566 'md_module' => $modules,
66 - 'md_skin' => $skin
 67+ 'md_skin' => $context->getSkin()
6768 ), __METHOD__
6869 );
6970
@@ -109,7 +110,7 @@
110111 * Runs JavaScript or CSS data through a filter, caching the filtered result for future calls.
111112 *
112113 * Available filters are:
113 - * - minify-js \see JavaScriptDistiller::stripWhiteSpace
 114+ * - minify-js \see JavaScriptMinifier::minify
114115 * - minify-css \see CSSMin::minify
115116 *
116117 * If $data is empty, only contains whitespace or the filter was unknown,
@@ -120,8 +121,7 @@
121122 * @return String: Filtered data, or a comment containing an error message
122123 */
123124 protected function filter( $filter, $data ) {
124 - global $wgResourceLoaderMinifyJSVerticalSpace;
125 -
 125+ global $wgResourceLoaderMinifierStatementsOnOwnLine, $wgResourceLoaderMinifierMaxLineLength;
126126 wfProfileIn( __METHOD__ );
127127
128128 // For empty/whitespace-only data or for unknown filters, don't perform
@@ -135,7 +135,7 @@
136136
137137 // Try for cache hit
138138 // Use CACHE_ANYTHING since filtering is very slow compared to DB queries
139 - $key = wfMemcKey( 'resourceloader', 'filter', $filter, md5( $data ) );
 139+ $key = wfMemcKey( 'resourceloader', 'filter', $filter, self::$filterCacheVersion, md5( $data ) );
140140 $cache = wfGetCache( CACHE_ANYTHING );
141141 $cacheEntry = $cache->get( $key );
142142 if ( is_string( $cacheEntry ) ) {
@@ -143,16 +143,20 @@
144144 return $cacheEntry;
145145 }
146146
 147+ $result = '';
147148 // Run the filter - we've already verified one of these will work
148149 try {
149150 switch ( $filter ) {
150151 case 'minify-js':
151 - $result = JavaScriptDistiller::stripWhiteSpace(
152 - $data, $wgResourceLoaderMinifyJSVerticalSpace
 152+ $result = JavaScriptMinifier::minify( $data,
 153+ $wgResourceLoaderMinifierStatementsOnOwnLine,
 154+ $wgResourceLoaderMinifierMaxLineLength
153155 );
 156+ $result .= "\n\n/* cache key: $key */\n";
154157 break;
155158 case 'minify-css':
156159 $result = CSSMin::minify( $data );
 160+ $result .= "\n\n/* cache key: $key */\n";
157161 break;
158162 }
159163
@@ -207,6 +211,7 @@
208212 foreach ( $name as $key => $value ) {
209213 $this->register( $key, $value );
210214 }
 215+ wfProfileOut( __METHOD__ );
211216 return;
212217 }
213218
@@ -252,7 +257,7 @@
253258 * Get the ResourceLoaderModule object for a given module name.
254259 *
255260 * @param $name String: Module name
256 - * @return Mixed: ResourceLoaderModule if module has been registered, null otherwise
 261+ * @return ResourceLoaderModule if module has been registered, null otherwise
257262 */
258263 public function getModule( $name ) {
259264 if ( !isset( $this->modules[$name] ) ) {
@@ -287,6 +292,7 @@
288293 */
289294 public function respond( ResourceLoaderContext $context ) {
290295 global $wgResourceLoaderMaxage, $wgCacheEpoch;
 296+
291297 // Buffer output to catch warnings. Normally we'd use ob_clean() on the
292298 // top-level output buffer to clear warnings, but that breaks when ob_gzhandler
293299 // is used: ob_clean() will clear the GZIP header in that case and it won't come
@@ -354,9 +360,9 @@
355361 wfProfileOut( __METHOD__.'-getModifiedTime' );
356362
357363 if ( $context->getOnly() === 'styles' ) {
358 - header( 'Content-Type: text/css' );
 364+ header( 'Content-Type: text/css; charset=utf-8' );
359365 } else {
360 - header( 'Content-Type: text/javascript' );
 366+ header( 'Content-Type: text/javascript; charset=utf-8' );
361367 }
362368 header( 'Last-Modified: ' . wfTimestamp( TS_RFC2822, $mtime ) );
363369 if ( $context->getDebug() ) {
@@ -378,7 +384,8 @@
379385 // Some clients send "timestamp;length=123". Strip the part after the first ';'
380386 // so we get a valid timestamp.
381387 $ims = $context->getRequest()->getHeader( 'If-Modified-Since' );
382 - if ( $ims !== false ) {
 388+ // Never send 304s in debug mode
 389+ if ( $ims !== false && !$context->getDebug() ) {
383390 $imsTS = strtok( $ims, ';' );
384391 if ( $mtime <= wfTimestamp( TS_UNIX, $imsTS ) ) {
385392 // There's another bug in ob_gzhandler (see also the comment at
@@ -419,7 +426,7 @@
420427
421428 // Remove the output buffer and output the response
422429 ob_end_clean();
423 - return $response;
 430+ echo $response;
424431
425432 wfProfileOut( __METHOD__ );
426433 }
@@ -441,6 +448,7 @@
442449 return '/* No modules requested. Max made me put this here */';
443450 }
444451
 452+ wfProfileIn( __METHOD__ );
445453 // Pre-fetch blobs
446454 if ( $context->shouldIncludeMessages() ) {
447455 try {
@@ -460,7 +468,9 @@
461469 // Scripts
462470 $scripts = '';
463471 if ( $context->shouldIncludeScripts() ) {
464 - $scripts .= $module->getScript( $context ) . "\n";
 472+ // bug 27054: Append semicolon to prevent weird bugs
 473+ // caused by files not terminating their statements right
 474+ $scripts .= $module->getScript( $context ) . ";\n";
465475 }
466476
467477 // Styles
@@ -484,7 +494,7 @@
485495 $out .= self::makeMessageSetScript( new XmlJsCode( $messagesBlob ) );
486496 break;
487497 default:
488 - // Minify CSS before embedding in mediaWiki.loader.implement call
 498+ // Minify CSS before embedding in mw.loader.implement call
489499 // (unless in debug mode)
490500 if ( !$context->getDebug() ) {
491501 foreach ( $styles as $media => $style ) {
@@ -521,21 +531,22 @@
522532 }
523533 }
524534
525 - if ( $context->getDebug() ) {
526 - return $exceptions . $out;
527 - } else {
 535+ if ( !$context->getDebug() ) {
528536 if ( $context->getOnly() === 'styles' ) {
529 - return $exceptions . $this->filter( 'minify-css', $out );
 537+ $out = $this->filter( 'minify-css', $out );
530538 } else {
531 - return $exceptions . $this->filter( 'minify-js', $out );
 539+ $out = $this->filter( 'minify-js', $out );
532540 }
533541 }
 542+
 543+ wfProfileOut( __METHOD__ );
 544+ return $exceptions . $out;
534545 }
535546
536547 /* Static Methods */
537548
538549 /**
539 - * Returns JS code to call to mediaWiki.loader.implement for a module with
 550+ * Returns JS code to call to mw.loader.implement for a module with
540551 * given properties.
541552 *
542553 * @param $name Module name
@@ -551,10 +562,10 @@
552563 $scripts = implode( $scripts, "\n" );
553564 }
554565 return Xml::encodeJsCall(
555 - 'mediaWiki.loader.implement',
 566+ 'mw.loader.implement',
556567 array(
557568 $name,
558 - new XmlJsCode( "function( $, mw ) {{$scripts}}" ),
 569+ new XmlJsCode( "function( $ ) {{$scripts}}" ),
559570 (object)$styles,
560571 (object)$messages
561572 ) );
@@ -567,7 +578,7 @@
568579 * JSON-encoded message blob containing the same data, wrapped in an XmlJsCode object.
569580 */
570581 public static function makeMessageSetScript( $messages ) {
571 - return Xml::encodeJsCall( 'mediaWiki.messages.set', array( (object)$messages ) );
 582+ return Xml::encodeJsCall( 'mw.messages.set', array( (object)$messages ) );
572583 }
573584
574585 /**
@@ -596,7 +607,7 @@
597608 }
598609
599610 /**
600 - * Returns a JS call to mediaWiki.loader.state, which sets the state of a
 611+ * Returns a JS call to mw.loader.state, which sets the state of a
601612 * module or modules to a given value. Has two calling conventions:
602613 *
603614 * - ResourceLoader::makeLoaderStateScript( $name, $state ):
@@ -607,9 +618,9 @@
608619 */
609620 public static function makeLoaderStateScript( $name, $state = null ) {
610621 if ( is_array( $name ) ) {
611 - return Xml::encodeJsCall( 'mediaWiki.loader.state', array( $name ) );
 622+ return Xml::encodeJsCall( 'mw.loader.state', array( $name ) );
612623 } else {
613 - return Xml::encodeJsCall( 'mediaWiki.loader.state', array( $name, $state ) );
 624+ return Xml::encodeJsCall( 'mw.loader.state', array( $name, $state ) );
614625 }
615626 }
616627
@@ -633,7 +644,7 @@
634645 }
635646
636647 /**
637 - * Returns JS code which calls mediaWiki.loader.register with the given
 648+ * Returns JS code which calls mw.loader.register with the given
638649 * parameters. Has three calling conventions:
639650 *
640651 * - ResourceLoader::makeLoaderRegisterScript( $name, $version, $dependencies, $group ):
Index: branches/MwEmbedStandAloneRL1_17/MwEmbedStandAlone/includes/resourceloader/ResourceLoaderContext.php
@@ -91,7 +91,8 @@
9292 if ( $this->direction === null ) {
9393 $this->direction = $this->request->getVal( 'dir' );
9494 if ( !$this->direction ) {
95 - $this->direction = Language::factory( $this->language )->getDir();
 95+ global $wgContLang;
 96+ $this->direction = $wgContLang->getDir();
9697 }
9798 }
9899 return $this->direction;
@@ -130,7 +131,7 @@
131132 }
132133
133134 public function getHash() {
134 - if ( isset( $this->hash ) ) {
 135+ if ( !isset( $this->hash ) ) {
135136 $this->hash = implode( '|', array(
136137 $this->getLanguage(), $this->getDirection(), $this->skin, $this->user,
137138 $this->debug, $this->only, $this->version
Index: branches/MwEmbedStandAloneRL1_17/MwEmbedStandAlone/includes/resourceloader/ResourceLoaderFileModule.php
@@ -102,8 +102,9 @@
103103 * to $IP
104104 * @param $remoteBasePath String: Base path to prepend to all remote paths in $options. Defaults
105105 * to $wgScriptPath
106 - *
107 - * @example $options
 106+ *
 107+ * Below is a description for the $options array:
 108+ * @code
108109 * array(
109110 * // Base path to prepend to all local paths in $options. Defaults to $IP
110111 * 'localBasePath' => [base path],
@@ -138,6 +139,7 @@
139140 * // Group which this module should be loaded together with
140141 * 'group' => [group name string],
141142 * )
 143+ * @endcode
142144 */
143145 public function __construct( $options = array(), $localBasePath = null,
144146 $remoteBasePath = null )
@@ -197,6 +199,8 @@
198200 break;
199201 }
200202 }
 203+ // Make sure the remote base path is a complete valid url
 204+ $this->remoteBasePath = wfExpandUrl( $this->remoteBasePath );
201205 }
202206
203207 /**
@@ -206,7 +210,6 @@
207211 * @return String: JavaScript code for $context
208212 */
209213 public function getScript( ResourceLoaderContext $context ) {
210 - global $wgServer;
211214 $files = array_merge(
212215 $this->scripts,
213216 self::tryForKey( $this->languageScripts, $context->getLanguage() ),
@@ -215,10 +218,10 @@
216219 if ( $context->getDebug() ) {
217220 $files = array_merge( $files, $this->debugScripts );
218221 if ( $this->debugRaw ) {
219 - $script = '';
 222+ $script = '';
220223 foreach ( $files as $file ) {
221224 $path = $this->getRemotePath( $file );
222 - $script .= "\n\t" . Xml::encodeJsCall( 'mediaWiki.loader.load', array( $path ) );
 225+ $script .= "\n\t" . Xml::encodeJsCall( 'mw.loader.load', array( $path ) );
223226 }
224227 return $script;
225228 }
@@ -354,6 +357,7 @@
355358 // If a module is nothing but a list of dependencies, we need to avoid
356359 // giving max() an empty array
357360 if ( count( $files ) === 0 ) {
 361+ wfProfileOut( __METHOD__ );
358362 return $this->modifiedTime[$context->getHash()] = 1;
359363 }
360364
@@ -363,6 +367,7 @@
364368 $this->modifiedTime[$context->getHash()] = max(
365369 $filesMtime,
366370 $this->getMsgBlobMtime( $context->getLanguage() ) );
 371+
367372 wfProfileOut( __METHOD__ );
368373 return $this->modifiedTime[$context->getHash()];
369374 }
@@ -508,4 +513,13 @@
509514 $style, $dir, $remoteDir, true
510515 );
511516 }
 517+
 518+ /**
 519+ * Get whether CSS for this module should be flipped
 520+ * @param $context ResourceLoaderContext
 521+ * @return bool
 522+ */
 523+ public function getFlip( $context ) {
 524+ return $context->getDirection() === 'rtl';
 525+ }
512526 }
Index: branches/MwEmbedStandAloneRL1_17/MwEmbedStandAlone/includes/resourceloader/ResourceLoaderModule.php
@@ -24,6 +24,34 @@
2525 * Abstraction for resource loader modules, with name registration and maxage functionality.
2626 */
2727 abstract class ResourceLoaderModule {
 28+
 29+ # Type of resource
 30+ const TYPE_SCRIPTS = 'scripts';
 31+ const TYPE_STYLES = 'styles';
 32+ const TYPE_MESSAGES = 'messages';
 33+ const TYPE_COMBINED = 'combined';
 34+
 35+ # sitewide core module like a skin file or jQuery component
 36+ const ORIGIN_CORE_SITEWIDE = 1;
 37+
 38+ # per-user module generated by the software
 39+ const ORIGIN_CORE_INDIVIDUAL = 2;
 40+
 41+ # sitewide module generated from user-editable files, like MediaWiki:Common.js, or
 42+ # modules accessible to multiple users, such as those generated by the Gadgets extension.
 43+ const ORIGIN_USER_SITEWIDE = 3;
 44+
 45+ # per-user module generated from user-editable files, like User:Me/vector.js
 46+ const ORIGIN_USER_INDIVIDUAL = 4;
 47+
 48+ # an access constant; make sure this is kept as the largest number in this group
 49+ const ORIGIN_ALL = 10;
 50+
 51+ # script and style modules form a hierarchy of trustworthiness, with core modules like
 52+ # skins and jQuery as most trustworthy, and user scripts as least trustworthy. We can
 53+ # limit the types of scripts and styles we allow to load on, say, sensitive special
 54+ # pages like Special:UserLogin and Special:Preferences
 55+ protected $origin = self::ORIGIN_CORE_SITEWIDE;
2856
2957 /* Protected Members */
3058
@@ -57,11 +85,34 @@
5886 }
5987
6088 /**
61 - * Get whether CSS for this module should be flipped
 89+ * Get this module's origin. This is set when the module is registered
 90+ * with ResourceLoader::register()
 91+ *
 92+ * @return Int ResourceLoaderModule class constant, the subclass default
 93+ * if not set manuall
 94+ */
 95+ public function getOrigin() {
 96+ return $this->origin;
 97+ }
 98+
 99+ /**
 100+ * Set this module's origin. This is called by ResourceLodaer::register()
 101+ * when registering the module. Other code should not call this.
 102+ *
 103+ * @param $name Int origin
 104+ */
 105+ public function setOrigin( $origin ) {
 106+ $this->origin = $origin;
 107+ }
 108+
 109+ /**
62110 * @param $context ResourceLoaderContext
 111+ * @return bool
63112 */
64113 public function getFlip( $context ) {
65 - return $context->getDirection() === 'rtl';
 114+ global $wgContLang;
 115+
 116+ return $wgContLang->getDir() !== $context->getDirection();
66117 }
67118
68119 /**
@@ -84,7 +135,7 @@
85136 */
86137 public function getStyles( ResourceLoaderContext $context ) {
87138 // Stub, override expected
88 - return '';
 139+ return array();
89140 }
90141
91142 /**
@@ -180,7 +231,7 @@
181232 * Get the last modification timestamp of the message blob for this
182233 * module in a given language.
183234 * @param $lang String: Language code
184 - * @return Integer: UNIX timestamp, or 0 if no blob found
 235+ * @return Integer: UNIX timestamp, or 0 if the module doesn't have messages
185236 */
186237 public function getMsgBlobMtime( $lang ) {
187238 if ( !isset( $this->msgBlobMtime[$lang] ) ) {
@@ -193,7 +244,12 @@
194245 'mr_lang' => $lang
195246 ), __METHOD__
196247 );
197 - $this->msgBlobMtime[$lang] = $msgBlobMtime ? wfTimestamp( TS_UNIX, $msgBlobMtime ) : 0;
 248+ // If no blob was found, but the module does have messages, that means we need
 249+ // to regenerate it. Return NOW
 250+ if ( $msgBlobMtime === false ) {
 251+ $msgBlobMtime = wfTimestampNow();
 252+ }
 253+ $this->msgBlobMtime[$lang] = wfTimestamp( TS_UNIX, $msgBlobMtime );
198254 }
199255 return $this->msgBlobMtime[$lang];
200256 }
@@ -224,4 +280,17 @@
225281 // 0 would mean now
226282 return 1;
227283 }
 284+
 285+ /**
 286+ * Check whether this module is known to be empty. If a child class
 287+ * has an easy and cheap way to determine that this module is
 288+ * definitely going to be empty, it should override this method to
 289+ * return true in that case. Callers may optimize the request for this
 290+ * module away if this function returns true.
 291+ * @param $context ResourceLoaderContext: Context object
 292+ * @return Boolean
 293+ */
 294+ public function isKnownEmpty( ResourceLoaderContext $context ) {
 295+ return false;
 296+ }
228297 }
Index: branches/MwEmbedStandAloneRL1_17/MwEmbedStandAlone/includes/resourceloader/README
@@ -0,0 +1,3 @@
 2+
 3+These resource loader files should support being copied directly from MediaWiki trunk without modification,
 4+this enables us to stay in-sync with resource loader updates.
\ No newline at end of file
Index: branches/MwEmbedStandAloneRL1_17/MwEmbedStandAlone/includes/resourceloader/ResourceLoaderStartUpModule.php
@@ -27,13 +27,17 @@
2828 protected $modifiedTime = array();
2929
3030 /* Protected Methods */
31 -
 31+
 32+ /**
 33+ * @param $context ResourceLoaderContext
 34+ * @return array
 35+ */
3236 protected function getConfig( $context ) {
3337 global $wgLoadScript, $wgScript, $wgStylePath, $wgScriptExtension,
3438 $wgArticlePath, $wgScriptPath, $wgServer, $wgContLang,
3539 $wgVariantArticlePath, $wgActionPaths, $wgUseAjax, $wgVersion,
3640 $wgEnableAPI, $wgEnableWriteAPI, $wgDBname, $wgEnableMWSuggest,
37 - $wgSitename, $wgFileExtensions;
 41+ $wgSitename, $wgFileExtensions, $wgExtensionAssetsPath, $wgProto;
3842
3943 // Pre-process information
4044 $separatorTransTable = $wgContLang->separatorTransformTable();
@@ -75,12 +79,15 @@
7680 'wgFormattedNamespaces' => $wgContLang->getFormattedNamespaces(),
7781 'wgNamespaceIds' => $wgContLang->getNamespaceIds(),
7882 'wgSiteName' => $wgSitename,
79 - 'wgFileExtensions' => $wgFileExtensions,
 83+ 'wgFileExtensions' => array_values( $wgFileExtensions ),
8084 'wgDBname' => $wgDBname,
 85+ // This sucks, it is only needed on Special:Upload, but I could
 86+ // not find a way to add vars only for a certain module
 87+ 'wgFileCanRotate' => BitmapHandler::canRotate(),
 88+ 'wgAvailableSkins' => Skin::getSkinNames(),
 89+ 'wgExtensionAssetsPath' => $wgExtensionAssetsPath,
 90+ 'wgProto' => $wgProto,
8191 );
82 - if ( $wgContLang->hasVariants() ) {
83 - $vars['wgUserVariant'] = $wgContLang->getPreferredVariant();
84 - }
8592 if ( $wgUseAjax && $wgEnableMWSuggest ) {
8693 $vars['wgMWSuggestTemplate'] = SearchEngine::getMWSuggestTemplate();
8794 }
@@ -111,25 +118,28 @@
112119 $deps = $module->getDependencies();
113120 $group = $module->getGroup();
114121 $version = wfTimestamp( TS_ISO_8601_BASIC,
115 - round( $module->getModifiedTime( $context ), -2 ) );
 122+ $module->getModifiedTime( $context ) );
116123 $out .= ResourceLoader::makeCustomLoaderScript( $name, $version, $deps, $group, $loader );
117124 }
118125 // Automatically register module
119126 else {
120 - $mtime = max( $module->getModifiedTime( $context ), wfTimestamp( TS_UNIX, $wgCacheEpoch ) );
 127+ // getModifiedTime() is supposed to return a UNIX timestamp, but it doesn't always
 128+ // seem to do that, and custom implementations might forget. Coerce it to TS_UNIX
 129+ $moduleMtime = wfTimestamp( TS_UNIX, $module->getModifiedTime( $context ) );
 130+ $mtime = max( $moduleMtime, wfTimestamp( TS_UNIX, $wgCacheEpoch ) );
121131 // Modules without dependencies or a group pass two arguments (name, timestamp) to
122 - // mediaWiki.loader.register()
 132+ // mw.loader.register()
123133 if ( !count( $module->getDependencies() && $module->getGroup() === null ) ) {
124134 $registrations[] = array( $name, $mtime );
125135 }
126136 // Modules with dependencies but no group pass three arguments
127 - // (name, timestamp, dependencies) to mediaWiki.loader.register()
 137+ // (name, timestamp, dependencies) to mw.loader.register()
128138 else if ( $module->getGroup() === null ) {
129139 $registrations[] = array(
130140 $name, $mtime, $module->getDependencies() );
131141 }
132142 // Modules with dependencies pass four arguments (name, timestamp, dependencies, group)
133 - // to mediaWiki.loader.register()
 143+ // to mw.loader.register()
134144 else {
135145 $registrations[] = array(
136146 $name, $mtime, $module->getDependencies(), $module->getGroup() );
@@ -146,17 +156,21 @@
147157
148158 public function getScript( ResourceLoaderContext $context ) {
149159 global $IP, $wgLoadScript;
 160+
150161 $out = file_get_contents( "$IP/resources/startup.js" );
151162 if ( $context->getOnly() === 'scripts' ) {
152 - // Get the latest version
153 - $version = 0;
154 -
 163+
 164+ // The core modules:
155165 $modules = array( 'jquery', 'mediawiki' );
156166 wfRunHooks( 'ResourceLoaderGetStartupModules', array( &$modules ) );
157 -
158 - foreach( $modules as $moduleName){
159 - $version = max( $version, $context->getResourceLoader()->getModule( $moduleName )->getModifiedTime( $context ) );
160 - }
 167+
 168+ // Get the latest version
 169+ $version = 0;
 170+ foreach ( $modules as $moduleName ) {
 171+ $version = max( $version,
 172+ $context->getResourceLoader()->getModule( $moduleName )->getModifiedTime( $context )
 173+ );
 174+ }
161175 // Build load query for StartupModules
162176 $query = array(
163177 'modules' => implode( '|', $modules ),
@@ -164,7 +178,7 @@
165179 'lang' => $context->getLanguage(),
166180 'skin' => $context->getSkin(),
167181 'debug' => $context->getDebug() ? 'true' : 'false',
168 - 'version' => wfTimestamp( TS_ISO_8601_BASIC, round( $version, -2 ) )
 182+ 'version' => wfTimestamp( TS_ISO_8601_BASIC, $version )
169183 );
170184 // Ensure uniform query order
171185 ksort( $query );
@@ -172,20 +186,22 @@
173187 // Startup function
174188 $configuration = $this->getConfig( $context );
175189 $registrations = self::getModuleRegistrations( $context );
176 - $out .= "var mwStartUp = function() {\n" .
177 - "\t" . Xml::encodeJsCall( 'mediaWiki.config.set', array( $configuration ) ) .
 190+ $out .= "var startUp = function() {\n" .
178191 "\t$registrations\n" .
 192+ "\t" . Xml::encodeJsCall( 'mediaWiki.config.set', array( $configuration ) ) .
179193 "};\n";
180194
181195 // Conditional script injection
182196 $scriptTag = Html::linkedScript( $wgLoadScript . '?' . wfArrayToCGI( $query ) );
183 - $out .= "if ( mwIsCompatible() ) {\n" .
 197+ $out .= "if ( isCompatible() ) {\n" .
184198 "\t" . Xml::encodeJsCall( 'document.write', array( $scriptTag ) ) .
185199 "}\n" .
186 - "delete mwIsCompatible;";
 200+ "delete isCompatible;";
187201 }
 202+
188203 return $out;
189204 }
 205+
190206 public function getModifiedTime( ResourceLoaderContext $context ) {
191207 global $IP, $wgCacheEpoch;
192208
@@ -210,12 +226,6 @@
211227 }
212228 return $this->modifiedTime[$hash] = $time;
213229 }
214 -
215 - public function getFlip( $context ) {
216 - global $wgContLang;
217 -
218 - return $wgContLang->getDir() !== $context->getDirection();
219 - }
220230
221231 /* Methods */
222232

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r85672Followup to r85464, correct parser testoverlordq16:17, 8 April 2011

Comments

#Comment by Bawolff (talk | contribs)   17:45, 8 April 2011

I think you got the revision number wrong in the commit summary. r85672 has to do with fixing parser tests for a change in math output.

#Comment by Mdale (talk | contribs)   17:51, 8 April 2011

yea I meant its up-to-date as of that revision of trunk, but should have been more specific and referenced the path I was dealing with: r85616

Status & tagging log