resourceloader: Remove ResourceLoaderMaxQueryLength from mw.config
authorTimo Tijhof <krinklemail@gmail.com>
Wed, 6 Mar 2019 15:46:44 +0000 (15:46 +0000)
committerTimo Tijhof <krinklemail@gmail.com>
Wed, 6 Mar 2019 15:57:56 +0000 (15:57 +0000)
This is only used internally. It doesn't need to be exported
as part of mw.config.

Change-Id: If4206d797b5d426eb999c34ad5dde3ba141c6f05

includes/resourceloader/ResourceLoaderStartUpModule.php
maintenance/jsduck/eg-iframe.html
resources/src/startup/mediawiki.js
tests/qunit/suites/resources/mediawiki/mediawiki.loader.test.js

index 16154ad..e344736 100644 (file)
@@ -114,7 +114,6 @@ class ResourceLoaderStartUpModule extends ResourceLoaderModule {
                        'wgCookieDomain' => $conf->get( 'CookieDomain' ),
                        'wgCookiePath' => $conf->get( 'CookiePath' ),
                        'wgCookieExpiration' => $conf->get( 'CookieExpiration' ),
-                       'wgResourceLoaderMaxQueryLength' => $conf->get( 'ResourceLoaderMaxQueryLength' ),
                        'wgCaseSensitiveNamespaces' => $caseSensitiveNamespaces,
                        'wgLegalTitleChars' => Title::convertByteClassToUnicodeClass( Title::legalChars() ),
                        'wgIllegalFileChars' => Title::convertByteClassToUnicodeClass( $illegalFileChars ),
@@ -409,6 +408,9 @@ class ResourceLoaderStartUpModule extends ResourceLoaderModule {
                // Perform replacements for mediawiki.js
                $mwLoaderPairs = [
                        '$VARS.baseModules' => ResourceLoader::encodeJsonForScript( $this->getBaseModules() ),
+                       '$VARS.maxQueryLength' => ResourceLoader::encodeJsonForScript(
+                               $conf->get( 'ResourceLoaderMaxQueryLength' )
+                       ),
                ];
                $profilerStubs = [
                        '$CODE.profileExecuteStart();' => 'mw.loader.profiler.onExecuteStart( module );',
index 3b83ea6..c1354e3 100644 (file)
                };
        </script>
        <script>
-               // Mock startup.js
+               // Mock ResourceLoaderStartUpModule substitutions
                window.$VARS = {
-                       baseModules: []
+                       baseModules: [],
+                       maxQueryLength: 2000
                };
+               // Mock startup.js
                window.RLQ = [];
        </script>
        <script src="modules/src/startup/mediawiki.js"></script>
index c08d259..28f57db 100644 (file)
                         * @param {string[]} batch
                         */
                        function batchRequest( batch ) {
-                               var reqBase, splits, maxQueryLength, b, bSource, bGroup,
+                               var reqBase, splits, b, bSource, bGroup,
                                        source, group, i, modules, sourceLoadScript,
                                        currReqBase, currReqBaseLength, moduleMap, currReqModules, l,
                                        lastDotIndex, prefix, suffix, bytesAdded;
                                        lang: mw.config.get( 'wgUserLanguage' ),
                                        debug: mw.config.get( 'debug' )
                                };
-                               maxQueryLength = mw.config.get( 'wgResourceLoaderMaxQueryLength', 2000 );
 
                                // Split module list by source and by group.
                                splits = Object.create( null );
                                                                modules[ i ].length + 3; // '%7C'.length == 3
 
                                                        // If the url would become too long, create a new one, but don't create empty requests
-                                                       if ( maxQueryLength > 0 && currReqModules.length && l + bytesAdded > maxQueryLength ) {
+                                                       if ( currReqModules.length && l + bytesAdded > mw.loader.maxQueryLength ) {
                                                                // Dispatch what we've got...
                                                                doRequest();
                                                                // .. and start again.
                                                                moduleMap = Object.create( null );
                                                                currReqModules = [];
 
-                                                               mw.track( 'resourceloader.splitRequest', { maxQueryLength: maxQueryLength } );
+                                                               mw.track( 'resourceloader.splitRequest', { maxQueryLength: mw.loader.maxQueryLength } );
                                                        }
                                                        if ( !moduleMap[ prefix ] ) {
                                                                moduleMap[ prefix ] = [];
                                 */
                                moduleRegistry: registry,
 
+                               /**
+                                * Exposed for testing and debugging only.
+                                *
+                                * @see #batchRequest
+                                * @property
+                                * @private
+                                */
+                               maxQueryLength: $VARS.maxQueryLength,
+
                                /**
                                 * @inheritdoc #newStyleTag
                                 * @method
index 8b06bd6..e17c78d 100644 (file)
@@ -15,6 +15,7 @@
                        };
                },
                teardown: function () {
+                       mw.loader.maxQueryLength = 2000;
                        // Teardown for StringSet shim test
                        if ( this.nativeSet ) {
                                window.Set = this.nativeSet;
                        [ 'testUrlIncDump', 'dump', [], null, 'testloader' ]
                ] );
 
-               mw.config.set( 'wgResourceLoaderMaxQueryLength', 10 );
+               mw.loader.maxQueryLength = 10;
 
                return mw.loader.using( [ 'testUrlIncDump', 'testUrlInc' ] ).then( function ( require ) {
                        assert.propEqual(