From: Timo Tijhof Date: Mon, 4 May 2020 20:30:24 +0000 (+0100) Subject: resourceloader: Let wgResourceLoaderMaxQueryLength=-1 fallback to default X-Git-Tag: 1.34.2~15 X-Git-Url: http://git.cyclocoop.org/?p=lhc%2Fweb%2Fwiklou.git;a=commitdiff_plain;h=d26ae7b17f48f3a84bb2e1934c16ead165a250a0 resourceloader: Let wgResourceLoaderMaxQueryLength=-1 fallback to default Follows-up 3ac385a0c39a622c. This was generated by the installer at some point and we've received two user reports of someone being caught by this. We don't need to support "unlimited" anymore, but at least make it do something more sensible, like using the default of 2000. Previously, it was effectively treating the -1 like 0, which was causing "debug mode"-like behaviour for end users. Bug: T251789 Change-Id: I483d5312e6fa25a0b00bb6173ed01eeb99ad42aa (cherry picked from commit fcd799ad54facda32aad127bbb4576fc2af078cc) --- diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 98738d7aff..f54e7e1162 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -3759,14 +3759,17 @@ $wgLegacyJavaScriptGlobals = true; /** * ResourceLoader will not generate URLs whose query string is more than * this many characters long, and will instead use multiple requests with - * shorter query strings. This degrades performance, but may be needed based - * on the query string limit supported by your web server and/or your user's - * web browsers. + * shorter query strings. Using multiple requests may degrade performance, + * but may be needed based on the query string limit supported by your web + * server and/or your user's web browsers. * + * Default: `2000`. + * + * @see ResourceLoaderStartUpModule::getMaxQueryLength * @since 1.17 * @var int */ -$wgResourceLoaderMaxQueryLength = 2000; +$wgResourceLoaderMaxQueryLength = false; /** * If set to true, JavaScript modules loaded from wiki pages will be parsed diff --git a/includes/resourceloader/ResourceLoaderStartUpModule.php b/includes/resourceloader/ResourceLoaderStartUpModule.php index df8126ed13..56fcb6c368 100644 --- a/includes/resourceloader/ResourceLoaderStartUpModule.php +++ b/includes/resourceloader/ResourceLoaderStartUpModule.php @@ -385,6 +385,21 @@ class ResourceLoaderStartUpModule extends ResourceLoaderModule { return 'MediaWikiModuleStore:' . $this->getConfig()->get( 'DBname' ); } + /** + * @see $wgResourceLoaderMaxQueryLength + * @return int + */ + private function getMaxQueryLength() : int { + $len = $this->getConfig()->get( 'ResourceLoaderMaxQueryLength' ); + // - Ignore -1, which in MW 1.34 and earlier was used to mean "unlimited". + // - Ignore invalid values, e.g. non-int or other negative values. + if ( $len === false || $len < 0 ) { + // Default + $len = 2000; + } + return $len; + } + /** * Get the key on which the JavaScript module cache (mw.loader.store) will vary. * @@ -428,9 +443,7 @@ class ResourceLoaderStartUpModule extends ResourceLoaderModule { $mwLoaderPairs = [ '$VARS.reqBase' => $context->encodeJson( $context->getReqBase() ), '$VARS.baseModules' => $context->encodeJson( $this->getBaseModules() ), - '$VARS.maxQueryLength' => $context->encodeJson( - $conf->get( 'ResourceLoaderMaxQueryLength' ) - ), + '$VARS.maxQueryLength' => $context->encodeJson( $this->getMaxQueryLength() ), // The client-side module cache can be disabled by site configuration. // It is also always disabled in debug mode. '$VARS.storeEnabled' => $context->encodeJson(