Merge "HTMLForm: Allow returning Message objects from HTMLFormField::validate()"
[lhc/web/wiklou.git] / includes / resourceloader / ResourceLoaderClientHtml.php
index dc70af4..91e0b02 100644 (file)
@@ -130,26 +130,15 @@ class ResourceLoaderClientHtml {
                        'states' => [
                                // moduleName => state
                        ],
-                       'general' => [
-                               // position => [ moduleName ]
-                               'top' => [],
-                               'bottom' => [],
-                       ],
+                       'general' => [],
                        'styles' => [
                                // moduleName
                        ],
-                       'scripts' => [
-                               // position => [ moduleName ]
-                               'top' => [],
-                               'bottom' => [],
-                       ],
+                       'scripts' => [],
                        // Embedding for private modules
                        'embed' => [
                                'styles' => [],
-                               'general' => [
-                                       'top' => [],
-                                       'bottom' => [],
-                               ],
+                               'general' => [],
                        ],
 
                ];
@@ -161,16 +150,15 @@ class ResourceLoaderClientHtml {
                        }
 
                        $group = $module->getGroup();
-                       $position = $module->getPosition();
 
                        if ( $group === 'private' ) {
                                // Embed via mw.loader.implement per T36907.
-                               $data['embed']['general'][$position][] = $name;
+                               $data['embed']['general'][] = $name;
                                // Avoid duplicate request from mw.loader
                                $data['states'][$name] = 'loading';
                        } else {
                                // Load via mw.loader.load()
-                               $data['general'][$position][] = $name;
+                               $data['general'][] = $name;
                        }
                }
 
@@ -216,14 +204,13 @@ class ResourceLoaderClientHtml {
                        }
 
                        $group = $module->getGroup();
-                       $position = $module->getPosition();
                        $context = $this->getContext( $group, ResourceLoaderModule::TYPE_SCRIPTS );
                        if ( $module->isKnownEmpty( $context ) ) {
                                // Avoid needless request for empty module
                                $data['states'][$name] = 'ready';
                        } else {
                                // Load from load.php?only=scripts via <script src></script>
-                               $data['scripts'][$position][] = $name;
+                               $data['scripts'][] = $name;
 
                                // Avoid duplicate request from mw.loader
                                $data['states'][$name] = 'loading';
@@ -282,24 +269,24 @@ class ResourceLoaderClientHtml {
                }
 
                // Inline RLQ: Embedded modules
-               if ( $data['embed']['general']['top'] ) {
+               if ( $data['embed']['general'] ) {
                        $chunks[] = $this->getLoad(
-                               $data['embed']['general']['top'],
+                               $data['embed']['general'],
                                ResourceLoaderModule::TYPE_COMBINED
                        );
                }
 
                // Inline RLQ: Load general modules
-               if ( $data['general']['top'] ) {
+               if ( $data['general'] ) {
                        $chunks[] = ResourceLoader::makeInlineScript(
-                               Xml::encodeJsCall( 'mw.loader.load', [ $data['general']['top'] ] )
+                               Xml::encodeJsCall( 'mw.loader.load', [ $data['general'] ] )
                        );
                }
 
                // Inline RLQ: Load only=scripts
-               if ( $data['scripts']['top'] ) {
+               if ( $data['scripts'] ) {
                        $chunks[] = $this->getLoad(
-                               $data['scripts']['top'],
+                               $data['scripts'],
                                ResourceLoaderModule::TYPE_SCRIPTS
                        );
                }
@@ -336,33 +323,7 @@ class ResourceLoaderClientHtml {
         * @return string|WrappedStringList HTML
         */
        public function getBodyHtml() {
-               $data = $this->getData();
-               $chunks = [];
-
-               // Inline RLQ: Embedded modules
-               if ( $data['embed']['general']['bottom'] ) {
-                       $chunks[] = $this->getLoad(
-                               $data['embed']['general']['bottom'],
-                               ResourceLoaderModule::TYPE_COMBINED
-                       );
-               }
-
-               // Inline RLQ: Load only=scripts
-               if ( $data['scripts']['bottom'] ) {
-                       $chunks[] = $this->getLoad(
-                               $data['scripts']['bottom'],
-                               ResourceLoaderModule::TYPE_SCRIPTS
-                       );
-               }
-
-               // Inline RLQ: Load general modules
-               if ( $data['general']['bottom'] ) {
-                       $chunks[] = ResourceLoader::makeInlineScript(
-                               Xml::encodeJsCall( 'mw.loader.load', [ $data['general']['bottom'] ] )
-                       );
-               }
-
-               return WrappedStringList::join( "\n", $chunks );
+               return '';
        }
 
        private function getContext( $group, $type ) {
@@ -429,6 +390,7 @@ class ResourceLoaderClientHtml {
                foreach ( $sortedModules as $source => $groups ) {
                        foreach ( $groups as $group => $grpModules ) {
                                $context = self::makeContext( $mainContext, $group, $only, $extraQuery );
+                               $context->setModules( array_keys( $grpModules ) );
 
                                if ( $group === 'private' ) {
                                        // Decide whether to use style or script element
@@ -456,11 +418,10 @@ class ResourceLoaderClientHtml {
                                // This should NOT be done for the site group (bug 27564) because anons get that too
                                // and we shouldn't be putting timestamps in CDN-cached HTML
                                if ( $group === 'user' ) {
-                                       $version = $rl->getCombinedVersion( $context, array_keys( $grpModules ) );
-                                       $context->setVersion( $version );
+                                       // Must setModules() before makeVersionQuery()
+                                       $context->setVersion( $rl->makeVersionQuery( $context ) );
                                }
 
-                               $context->setModules( array_keys( $grpModules ) );
                                $url = $rl->createLoaderURL( $source, $context, $extraQuery );
 
                                // Decide whether to use 'style' or 'script' element