Merge "resourceloader: Reduce width of module hash from 7 chars to 5"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Tue, 3 Sep 2019 19:21:39 +0000 (19:21 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Tue, 3 Sep 2019 19:21:39 +0000 (19:21 +0000)
1  2 
includes/resourceloader/ResourceLoaderStartUpModule.php
resources/src/startup/mediawiki.js

@@@ -104,7 -104,6 +104,7 @@@ class ResourceLoaderStartUpModule exten
                        'wgContentNamespaces' => $nsInfo->getContentNamespaces(),
                        'wgSiteName' => $conf->get( 'Sitename' ),
                        'wgDBname' => $conf->get( 'DBname' ),
 +                      'wgWikiID' => WikiMap::getWikiIdFromDbDomain( WikiMap::getCurrentWikiDbDomain() ),
                        'wgExtraSignatureNamespaces' => $conf->get( 'ExtraSignatureNamespaces' ),
                        'wgExtensionAssetsPath' => $conf->get( 'ExtensionAssetsPath' ),
                        // MediaWiki sets cookies to have this prefix by default
                                $states[$name] = 'error';
                        }
  
-                       if ( $versionHash !== '' && strlen( $versionHash ) !== 7 ) {
+                       if ( $versionHash !== '' && strlen( $versionHash ) !== ResourceLoader::HASH_LENGTH ) {
                                $e = new RuntimeException( "Badly formatted module version hash" );
                                $resourceLoader->outputErrorAndLog( $e,
                                                "Module '{module}' produced an invalid version hash: '{version}'.",
@@@ -37,8 -37,8 +37,8 @@@
                        hash ^= str.charCodeAt( i );
                }
  
-               hash = ( hash >>> 0 ).toString( 36 );
-               while ( hash.length < 7 ) {
+               hash = ( hash >>> 0 ).toString( 36 ).slice( 0, 5 );
+               while ( hash.length < 5 ) {
                        hash = '0' + hash;
                }
                /* eslint-enable no-bitwise */
  
                                                // In addition to currReqBase, doRequest() will also add 'modules' and 'version'.
                                                // > '&modules='.length === 9
-                                               // > '&version=1234567'.length === 16
-                                               // > 9 + 16 = 25
-                                               currReqBaseLength = makeQueryString( currReqBase ).length + 25;
+                                               // > '&version=12345'.length === 14
+                                               // > 9 + 14 = 23
+                                               currReqBaseLength = makeQueryString( currReqBase ).length + 23;
  
                                                // We may need to split up the request to honor the query string length limit,
                                                // so build it piece by piece.
                                        }() )
                                }
                        };
 -              }() ),
 -
 -              // Skeleton user object, extended by the 'mediawiki.user' module.
 -              /**
 -               * @class mw.user
 -               * @singleton
 -               */
 -              user: {
 -                      /**
 -                       * @property {mw.Map}
 -                       */
 -                      options: new Map(),
 -                      /**
 -                       * @property {mw.Map}
 -                       */
 -                      tokens: new Map()
 -              }
 -
 +              }() )
        };
  
        // Attach to window and globally alias