r75107 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r75106‎ | r75107 | r75108 >
Date:20:43, 20 October 2010
Author:tparscal
Status:ok (Comments)
Tags:
Comment:
* Improves on r75054 and r75036 by adding comments and renaming variables
* Fixes issue cased by creating a file module that only contains a list of dependencies.
Modified paths:
  • /trunk/phase3/includes/resourceloader/ResourceLoaderFileModule.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/resourceloader/ResourceLoaderFileModule.php
@@ -29,27 +29,60 @@
3030
3131 /* Protected Members */
3232
33 - /** @var {array} List of paths to JavaScript files to always include */
 33+ /**
 34+ * @var {array} List of paths to JavaScript files to always include
 35+ * @format array( [file-path], [file-path], ... )
 36+ */
3437 protected $scripts = array();
35 - /** @var {array} List of paths to JavaScript files to include when using specific languages */
 38+ /**
 39+ * @var {array} List of JavaScript files to include when using a specific language
 40+ * @format array( [language-code] => array( [file-path], [file-path], ... ), ... )
 41+ */
3642 protected $languageScripts = array();
37 - /** @var {array} List of paths to JavaScript files to include when using specific skins */
 43+ /**
 44+ * @var {array} List of JavaScript files to include when using a specific skin
 45+ * @format array( [skin-name] => array( [file-path], [file-path], ... ), ... )
 46+ */
3847 protected $skinScripts = array();
39 - /** @var {array} List of paths to JavaScript files to include in debug mode */
 48+ /**
 49+ * @var {array} List of paths to JavaScript files to include in debug mode
 50+ * @format array( [skin-name] => array( [file-path], [file-path], ... ), ... )
 51+ */
4052 protected $debugScripts = array();
41 - /** @var {array} List of paths to JavaScript files to include in the startup module */
 53+ /**
 54+ * @var {array} List of paths to JavaScript files to include in the startup module
 55+ * @format array( [file-path], [file-path], ... )
 56+ */
4257 protected $loaderScripts = array();
43 - /** @var {array} List of paths to CSS files to always include */
 58+ /**
 59+ * @var {array} List of paths to CSS files to always include
 60+ * @format array( [file-path], [file-path], ... )
 61+ */
4462 protected $styles = array();
45 - /** @var {array} List of paths to CSS files to include when using specific skins */
 63+ /**
 64+ * @var {array} List of paths to CSS files to include when using specific skins
 65+ * @format array( [file-path], [file-path], ... )
 66+ */
4667 protected $skinStyles = array();
47 - /** @var {array} List of modules this module depends on */
 68+ /**
 69+ * @var {array} List of modules this module depends on
 70+ * @format array( [file-path], [file-path], ... )
 71+ */
4872 protected $dependencies = array();
49 - /** @var {array} List of message keys used by this module */
 73+ /**
 74+ * @var {array} List of message keys used by this module
 75+ * @format array( [module-name], [module-name], ... )
 76+ */
5077 protected $messages = array();
51 - /** @var {array} Name of group this module should be loaded in */
 78+ /**
 79+ * @var {string} Name of group this module should be loaded in
 80+ * @format array( [message-key], [message-key], ... )
 81+ */
5282 protected $group;
53 - /** @var {array} Cache for mtime */
 83+ /**
 84+ * @var {array} Cache for mtime
 85+ * @format array( [hash] => [mtime], [hash] => [mtime], ... )
 86+ */
5487 protected $modifiedTime = array();
5588
5689 /* Methods */
@@ -253,6 +286,11 @@
254287 $this->getFileDependencies( $context->getSkin() )
255288 );
256289
 290+ // If a module is nothing but a list of dependencies, we need to avoid giving max() an empty array
 291+ if ( count( $files ) === 0 ) {
 292+ return $this->modifiedTime[$context->getHash()] = 1;
 293+ }
 294+
257295 wfProfileIn( __METHOD__.'-filemtime' );
258296 $filesMtime = max( array_map( 'filemtime', array_map( array( __CLASS__, 'resolveFilePath' ), $files ) ) );
259297 wfProfileOut( __METHOD__.'-filemtime' );
@@ -301,11 +339,11 @@
302340 $collatedFiles[$default][] = $value;
303341 } else if ( is_array( $value ) ) {
304342 // File name as the key, options array as the value
305 - $media = isset( $value[$option] ) ? $value[$option] : $default;
306 - if ( !isset( $collatedFiles[$media] ) ) {
307 - $collatedFiles[$media] = array();
 343+ $optionValue = isset( $value[$option] ) ? $value[$option] : $default;
 344+ if ( !isset( $collatedFiles[$optionValue] ) ) {
 345+ $collatedFiles[$optionValue] = array();
308346 }
309 - $collatedFiles[$media][] = $key;
 347+ $collatedFiles[$optionValue][] = $key;
310348 }
311349 }
312350 return $collatedFiles;

Follow-up revisions

RevisionCommit summaryAuthorDate
r75468Fixes comment mistakes in r75107tparscal20:17, 26 October 2010

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r75036Fixed ResourceLoaderFileModule constructor - collated lists were not being p...tparscal20:59, 19 October 2010
r75054Refactored ResourceLoaderFileModule, most notably removing the set* methods, ...tparscal22:48, 19 October 2010

Comments

#Comment by Catrope (talk | contribs)   19:49, 26 October 2010
+	/**
+	 * @var {array} List of message keys used by this module
+	 * @format array( [module-name], [module-name], ... )
+	 */
 	protected $messages = array();

Did you mean [message-key]?

Status & tagging log