* In ResourceLoaderContext, lazy-load $this->direction and $this->language, to avoid loading the whole English localisation for load.php requests which never call getHash().
* Interpreted some Trevor-speak in the doc comment of ResourceLoader::preloadModuleInfo(). * Made setMsgBlobMtime() (called from preloadModuleInfo()) actually work, by making getMsgBlobMtime() use the cached blob times if they are available.
This commit is contained in:
parent
6dcca60f65
commit
ec2acb239b
3 changed files with 28 additions and 24 deletions
|
|
@ -41,9 +41,9 @@ class ResourceLoader {
|
|||
* This method grabs modules dependencies from the database and updates modules
|
||||
* objects.
|
||||
*
|
||||
* This is not inside the module code because it's so much more performant to
|
||||
* This is not inside the module code because it is much faster to
|
||||
* request all of the information at once than it is to have each module
|
||||
* requests its own information. This sacrifice of modularity yields a profound
|
||||
* requests its own information. This sacrifice of modularity yields a substantial
|
||||
* performance improvement.
|
||||
*
|
||||
* @param $modules Array: List of module names to preload information for
|
||||
|
|
|
|||
|
|
@ -53,23 +53,12 @@ class ResourceLoaderContext {
|
|||
$modules = $request->getVal( 'modules' );
|
||||
$this->modules = $modules ? explode( '|', $modules ) : array();
|
||||
// Various parameters
|
||||
$this->language = $request->getVal( 'lang' );
|
||||
$this->direction = $request->getVal( 'dir' );
|
||||
$this->skin = $request->getVal( 'skin' );
|
||||
$this->user = $request->getVal( 'user' );
|
||||
$this->debug = $request->getFuzzyBool( 'debug', $wgResourceLoaderDebug );
|
||||
$this->only = $request->getVal( 'only' );
|
||||
$this->version = $request->getVal( 'version' );
|
||||
|
||||
// Fallback on system defaults
|
||||
if ( !$this->language ) {
|
||||
$this->language = $wgLang->getCode();
|
||||
}
|
||||
|
||||
if ( !$this->direction ) {
|
||||
$this->direction = Language::factory( $this->language )->getDir();
|
||||
}
|
||||
|
||||
if ( !$this->skin ) {
|
||||
$this->skin = $wgDefaultSkin;
|
||||
}
|
||||
|
|
@ -88,10 +77,23 @@ class ResourceLoaderContext {
|
|||
}
|
||||
|
||||
public function getLanguage() {
|
||||
if ( $this->language === null ) {
|
||||
global $wgLang;
|
||||
$this->language = $this->request->getVal( 'lang' );
|
||||
if ( !$this->language ) {
|
||||
$this->language = $wgLang->getCode();
|
||||
}
|
||||
}
|
||||
return $this->language;
|
||||
}
|
||||
|
||||
public function getDirection() {
|
||||
if ( $this->direction === null ) {
|
||||
$this->direction = $this->request->getVal( 'dir' );
|
||||
if ( !$this->direction ) {
|
||||
$this->direction = Language::factory( $this->language )->getDir();
|
||||
}
|
||||
}
|
||||
return $this->direction;
|
||||
}
|
||||
|
||||
|
|
@ -130,7 +132,7 @@ class ResourceLoaderContext {
|
|||
public function getHash() {
|
||||
if ( isset( $this->hash ) ) {
|
||||
$this->hash = implode( '|', array(
|
||||
$this->language, $this->direction, $this->skin, $this->user,
|
||||
$this->getLanguage(), $this->getDirection(), $this->skin, $this->user,
|
||||
$this->debug, $this->only, $this->version
|
||||
) );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -182,16 +182,18 @@ abstract class ResourceLoaderModule {
|
|||
* @return Integer: UNIX timestamp, or 0 if no blob found
|
||||
*/
|
||||
public function getMsgBlobMtime( $lang ) {
|
||||
if ( !count( $this->getMessages() ) )
|
||||
return 0;
|
||||
|
||||
$dbr = wfGetDB( DB_SLAVE );
|
||||
$msgBlobMtime = $dbr->selectField( 'msg_resource', 'mr_timestamp', array(
|
||||
'mr_resource' => $this->getName(),
|
||||
'mr_lang' => $lang
|
||||
), __METHOD__
|
||||
);
|
||||
$this->msgBlobMtime[$lang] = $msgBlobMtime ? wfTimestamp( TS_UNIX, $msgBlobMtime ) : 0;
|
||||
if ( !isset( $this->msgBlobMtime[$lang] ) ) {
|
||||
if ( !count( $this->getMessages() ) )
|
||||
return 0;
|
||||
|
||||
$dbr = wfGetDB( DB_SLAVE );
|
||||
$msgBlobMtime = $dbr->selectField( 'msg_resource', 'mr_timestamp', array(
|
||||
'mr_resource' => $this->getName(),
|
||||
'mr_lang' => $lang
|
||||
), __METHOD__
|
||||
);
|
||||
$this->msgBlobMtime[$lang] = $msgBlobMtime ? wfTimestamp( TS_UNIX, $msgBlobMtime ) : 0;
|
||||
}
|
||||
return $this->msgBlobMtime[$lang];
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue