resourceloader: Let wgResourceLoaderMaxQueryLength=-1 fallback to default
[lhc/web/wiklou.git] / includes / resourceloader / ResourceLoaderStartUpModule.php
index df8126e..56fcb6c 100644 (file)
@@ -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(