* 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
$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;
}
}
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;
}
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
) );
}
* @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];
}