Index: trunk/phase3/includes/resourceloader/ResourceLoaderStartUpModule.php |
— | — | @@ -37,7 +37,8 @@ |
38 | 38 | $wgArticlePath, $wgScriptPath, $wgServer, $wgContLang, |
39 | 39 | $wgVariantArticlePath, $wgActionPaths, $wgUseAjax, $wgVersion, |
40 | 40 | $wgEnableAPI, $wgEnableWriteAPI, $wgDBname, $wgEnableMWSuggest, |
41 | | - $wgSitename, $wgFileExtensions, $wgExtensionAssetsPath, $wgProto, $wgCookiePrefix; |
| 41 | + $wgSitename, $wgFileExtensions, $wgExtensionAssetsPath, $wgProto, |
| 42 | + $wgCookiePrefix, $wgResourceLoaderMaxQueryLength; |
42 | 43 | |
43 | 44 | // Pre-process information |
44 | 45 | $separatorTransTable = $wgContLang->separatorTransformTable(); |
— | — | @@ -92,6 +93,7 @@ |
93 | 94 | 'wgProto' => $wgProto, |
94 | 95 | // mediawiki sets cookies to have this prefix by default |
95 | 96 | 'wgCookiePrefix' => $wgCookiePrefix, |
| 97 | + 'wgResourceLoaderMaxQueryLength' => $wgResourceLoaderMaxQueryLength, |
96 | 98 | ); |
97 | 99 | if ( $wgUseAjax && $wgEnableMWSuggest ) { |
98 | 100 | $vars['wgMWSuggestTemplate'] = SearchEngine::getMWSuggestTemplate(); |
Index: trunk/phase3/includes/DefaultSettings.php |
— | — | @@ -2537,6 +2537,19 @@ |
2538 | 2538 | */ |
2539 | 2539 | $wgIncludeLegacyJavaScript = true; |
2540 | 2540 | |
| 2541 | +/** |
| 2542 | + * If set to a positive number, ResourceLoader will not generate URLs whose |
| 2543 | + * query string is more than this many characters long, and will instead use |
| 2544 | + * multiple requests with shorter query strings. This degrades performance, |
| 2545 | + * but may be needed if your web server has a low (less than, say 1024) |
| 2546 | + * query string length limit or a low value for suhosin.get.max_value_length |
| 2547 | + * that you can't increase. |
| 2548 | + * |
| 2549 | + * If set to a negative number, ResourceLoader will assume there is no query |
| 2550 | + * string length limit. |
| 2551 | + */ |
| 2552 | +$wgResourceLoaderMaxQueryLength = -1; |
| 2553 | + |
2541 | 2554 | /** @} */ # End of resource loader settings } |
2542 | 2555 | |
2543 | 2556 | |
Index: trunk/phase3/resources/mediawiki/mediawiki.js |
— | — | @@ -922,9 +922,38 @@ |
923 | 923 | version = registry[groups[group][g]].version; |
924 | 924 | } |
925 | 925 | } |
926 | | - requests[requests.length] = $.extend( |
927 | | - { 'modules': groups[group].join( '|' ), 'version': formatVersionNumber( version ) }, base |
928 | | - ); |
| 926 | + var reqBase = $.extend( { 'version': formatVersionNumber( version ) }, base ); |
| 927 | + var reqBaseLength = $.param( reqBase ).length; |
| 928 | + var reqs = []; |
| 929 | + var limit = mw.config.get( 'wgResourceLoaderMaxQueryLength', -1 ); |
| 930 | + if ( limit > 0 ) { |
| 931 | + // We may need to split up the request to honor the query string length limit |
| 932 | + // So build it piece by piece |
| 933 | + var l = reqBaseLength + 9; // '&modules='.length == 9 |
| 934 | + var r = 0; |
| 935 | + reqs[0] = []; |
| 936 | + for ( var i = 0; i < groups[group].length; i++ ) { |
| 937 | + // If the request would become too long, create a new one, |
| 938 | + // but don't create empty requests |
| 939 | + // '%7C'.length == 3 |
| 940 | + if ( reqs[r].length > 0 && l + 3 + groups[group][i].length > limit ) { |
| 941 | + // This request would become too long, create a new one |
| 942 | + r++; |
| 943 | + reqs[r] = []; |
| 944 | + l = reqBaseLength + 9; |
| 945 | + } |
| 946 | + reqs[r][reqs[r].length] = groups[group][i]; |
| 947 | + l += groups[group][i].length + 3; |
| 948 | + } |
| 949 | + } else { |
| 950 | + // No splitting needed |
| 951 | + reqs = [ groups[group] ]; |
| 952 | + } |
| 953 | + for ( var r in reqs ) { |
| 954 | + requests[requests.length] = $.extend( |
| 955 | + { 'modules': reqs[r].join( '|' ) }, reqBase |
| 956 | + ); |
| 957 | + } |
929 | 958 | } |
930 | 959 | // Clear the batch - this MUST happen before we append the |
931 | 960 | // script element to the body or it's possible that the script |