Merge "Drop SessionManager::autoCreateUser(), deprecated in 1.27 and unused"
[lhc/web/wiklou.git] / includes / resourceloader / ResourceLoaderModule.php
index a507ad3..ae79dda 100644 (file)
@@ -159,8 +159,20 @@ abstract class ResourceLoaderModule implements LoggerAwareInterface {
         * Get all JS for this module for a given language and skin.
         * Includes all relevant JS except loader scripts.
         *
+        * For "plain" script modules, this should return a string with JS code. For multi-file modules
+        * where require() is used to load one file from another file, this should return an array
+        * structured as follows:
+        * [
+        *     'files' => [
+        *         'file1.js' => [ 'type' => 'script', 'content' => 'JS code' ],
+        *         'file2.js' => [ 'type' => 'script', 'content' => 'JS code' ],
+        *         'data.json' => [ 'type' => 'data', 'content' => array ]
+        *     ],
+        *     'main' => 'file1.js'
+        * ]
+        *
         * @param ResourceLoaderContext $context
-        * @return string JavaScript code
+        * @return string|array JavaScript code (string), or multi-file structure described above (array)
         */
        public function getScript( ResourceLoaderContext $context ) {
                // Stub, override expected
@@ -691,7 +703,7 @@ abstract class ResourceLoaderModule implements LoggerAwareInterface {
 
                // This MUST build both scripts and styles, regardless of whether $context->getOnly()
                // is 'scripts' or 'styles' because the result is used by getVersionHash which
-               // must be consistent regardles of the 'only' filter on the current request.
+               // must be consistent regardless of the 'only' filter on the current request.
                // Also, when introducing new module content resources (e.g. templates, headers),
                // these should only be included in the array when they are non-empty so that
                // existing modules not using them do not get their cache invalidated.
@@ -813,7 +825,7 @@ abstract class ResourceLoaderModule implements LoggerAwareInterface {
                        } else {
                                // Infer changes based on definition and other metrics
                                $summary = $this->getDefinitionSummary( $context );
-                               if ( !isset( $summary['_cacheEpoch'] ) ) {
+                               if ( !isset( $summary['_class'] ) ) {
                                        throw new LogicException( 'getDefinitionSummary must call parent method' );
                                }
                                $str = json_encode( $summary );
@@ -883,7 +895,9 @@ abstract class ResourceLoaderModule implements LoggerAwareInterface {
        public function getDefinitionSummary( ResourceLoaderContext $context ) {
                return [
                        '_class' => static::class,
-                       '_cacheEpoch' => $this->getConfig()->get( 'CacheEpoch' ),
+                       // Make sure that when filter cache for minification is invalidated,
+                       // we also change the HTTP urls and mw.loader.store keys (T176884).
+                       '_cacheVersion' => ResourceLoader::CACHE_VERSION,
                ];
        }