/**
* Gets list of names of modules this module depends on.
- *
+ * @param ResourceLoaderContext context
* @return array List of module names
*/
- public function getDependencies() {
+ public function getDependencies( ResourceLoaderContext $context = null ) {
return $this->dependencies;
}
}
/**
- * Helper method to gather file mtimes for getDefinitionSummary.
+ * Disable module content versioning.
+ *
+ * This class uses getDefinitionSummary() instead, to avoid filesystem overhead
+ * involved with building the full module content inside a startup request.
+ *
+ * @return bool
+ */
+ public function enableModuleContentVersion() {
+ return false;
+ }
+
+ /**
+ * Helper method to gather file hashes for getDefinitionSummary.
*
- * Last modified timestamps are calculated from the highest last modified
- * timestamp of this module's constituent files as well as the files it
- * depends on. This function is context-sensitive, only performing
- * calculations on files relevant to the given language, skin and debug
- * mode.
+ * This function is context-sensitive, only computing hashes of files relevant to the
+ * given language, skin, etc.
*
* @see ResourceLoaderModule::getFileDependencies
* @param ResourceLoaderContext $context
* @return array
*/
- protected function getFileMtimes( ResourceLoaderContext $context ) {
+ protected function getFileHashes( ResourceLoaderContext $context ) {
$files = array();
// Flatten style files into $files
// entry point Less file we already know about.
$files = array_values( array_unique( $files ) );
- // Don't max() because older files are significant.
- // While the associated file names are significant, that is already taken care of by the
- // definition summary. Avoid creating an array keyed by file path here because those are
- // absolute file paths. Including that would needlessly cause global cache invalidation
- // when the MediaWiki installation path changes (which is quite common in cases like
- // Wikimedia where the installation path reflects the MediaWiki branch name).
- return array_map( array( __CLASS__, 'safeFilemtime' ), $files );
+ // Don't include keys or file paths here, only the hashes. Including that would needlessly
+ // cause global cache invalidation when files move or if e.g. the MediaWiki path changes.
+ // Any significant ordering is already detected by the definition summary.
+ return array_map( array( __CLASS__, 'safeFileHash' ), $files );
}
/**
$options = array();
foreach ( array(
+ // The following properties are omitted because they don't affect the module reponse:
+ // - localBasePath (Per T104950; Changes when absolute directory name changes. If
+ // this affects 'scripts' and other file paths, getFileHashes accounts for that.)
+ // - remoteBasePath (Per T104950)
+ // - dependencies (provided via startup module)
+ // - targets
+ // - group (provided via startup module)
+ // - position (only used by OutputPage)
'scripts',
'debugScripts',
'loaderScripts',
'languageScripts',
'skinScripts',
'skinStyles',
- 'dependencies',
'messages',
- 'targets',
'templates',
- 'group',
- 'position',
'skipFunction',
- // FIXME: localBasePath includes the MediaWiki installation path and
- // needlessly causes cache invalidation.
- 'localBasePath',
- 'remoteBasePath',
'debugRaw',
'raw',
) as $member ) {
$summary[] = array(
'options' => $options,
- 'fileMtimes' => $this->getFileMTimes( $context ),
+ 'fileHashes' => $this->getFileHashes( $context ),
'msgBlobMtime' => $this->getMsgBlobMtime( $context->getLanguage() ),
);
return $summary;