Index: trunk/phase3/includes/resourceloader/ResourceLoader.php |
— | — | @@ -41,9 +41,9 @@ |
42 | 42 | * This method grabs modules dependencies from the database and updates modules |
43 | 43 | * objects. |
44 | 44 | * |
45 | | - * This is not inside the module code because it's so much more performant to |
| 45 | + * This is not inside the module code because it is much faster to |
46 | 46 | * request all of the information at once than it is to have each module |
47 | | - * requests its own information. This sacrifice of modularity yields a profound |
| 47 | + * requests its own information. This sacrifice of modularity yields a substantial |
48 | 48 | * performance improvement. |
49 | 49 | * |
50 | 50 | * @param $modules Array: List of module names to preload information for |
Index: trunk/phase3/includes/resourceloader/ResourceLoaderContext.php |
— | — | @@ -53,23 +53,12 @@ |
54 | 54 | $modules = $request->getVal( 'modules' ); |
55 | 55 | $this->modules = $modules ? explode( '|', $modules ) : array(); |
56 | 56 | // Various parameters |
57 | | - $this->language = $request->getVal( 'lang' ); |
58 | | - $this->direction = $request->getVal( 'dir' ); |
59 | 57 | $this->skin = $request->getVal( 'skin' ); |
60 | 58 | $this->user = $request->getVal( 'user' ); |
61 | 59 | $this->debug = $request->getFuzzyBool( 'debug', $wgResourceLoaderDebug ); |
62 | 60 | $this->only = $request->getVal( 'only' ); |
63 | 61 | $this->version = $request->getVal( 'version' ); |
64 | 62 | |
65 | | - // Fallback on system defaults |
66 | | - if ( !$this->language ) { |
67 | | - $this->language = $wgLang->getCode(); |
68 | | - } |
69 | | - |
70 | | - if ( !$this->direction ) { |
71 | | - $this->direction = Language::factory( $this->language )->getDir(); |
72 | | - } |
73 | | - |
74 | 63 | if ( !$this->skin ) { |
75 | 64 | $this->skin = $wgDefaultSkin; |
76 | 65 | } |
— | — | @@ -88,10 +77,23 @@ |
89 | 78 | } |
90 | 79 | |
91 | 80 | public function getLanguage() { |
| 81 | + if ( $this->language === null ) { |
| 82 | + global $wgLang; |
| 83 | + $this->language = $this->request->getVal( 'lang' ); |
| 84 | + if ( !$this->language ) { |
| 85 | + $this->language = $wgLang->getCode(); |
| 86 | + } |
| 87 | + } |
92 | 88 | return $this->language; |
93 | 89 | } |
94 | 90 | |
95 | 91 | public function getDirection() { |
| 92 | + if ( $this->direction === null ) { |
| 93 | + $this->direction = $this->request->getVal( 'dir' ); |
| 94 | + if ( !$this->direction ) { |
| 95 | + $this->direction = Language::factory( $this->language )->getDir(); |
| 96 | + } |
| 97 | + } |
96 | 98 | return $this->direction; |
97 | 99 | } |
98 | 100 | |
— | — | @@ -130,7 +132,7 @@ |
131 | 133 | public function getHash() { |
132 | 134 | if ( isset( $this->hash ) ) { |
133 | 135 | $this->hash = implode( '|', array( |
134 | | - $this->language, $this->direction, $this->skin, $this->user, |
| 136 | + $this->getLanguage(), $this->getDirection(), $this->skin, $this->user, |
135 | 137 | $this->debug, $this->only, $this->version |
136 | 138 | ) ); |
137 | 139 | } |
Index: trunk/phase3/includes/resourceloader/ResourceLoaderModule.php |
— | — | @@ -182,16 +182,18 @@ |
183 | 183 | * @return Integer: UNIX timestamp, or 0 if no blob found |
184 | 184 | */ |
185 | 185 | public function getMsgBlobMtime( $lang ) { |
186 | | - if ( !count( $this->getMessages() ) ) |
187 | | - return 0; |
188 | | - |
189 | | - $dbr = wfGetDB( DB_SLAVE ); |
190 | | - $msgBlobMtime = $dbr->selectField( 'msg_resource', 'mr_timestamp', array( |
191 | | - 'mr_resource' => $this->getName(), |
192 | | - 'mr_lang' => $lang |
193 | | - ), __METHOD__ |
194 | | - ); |
195 | | - $this->msgBlobMtime[$lang] = $msgBlobMtime ? wfTimestamp( TS_UNIX, $msgBlobMtime ) : 0; |
| 186 | + if ( !isset( $this->msgBlobMtime[$lang] ) ) { |
| 187 | + if ( !count( $this->getMessages() ) ) |
| 188 | + return 0; |
| 189 | + |
| 190 | + $dbr = wfGetDB( DB_SLAVE ); |
| 191 | + $msgBlobMtime = $dbr->selectField( 'msg_resource', 'mr_timestamp', array( |
| 192 | + 'mr_resource' => $this->getName(), |
| 193 | + 'mr_lang' => $lang |
| 194 | + ), __METHOD__ |
| 195 | + ); |
| 196 | + $this->msgBlobMtime[$lang] = $msgBlobMtime ? wfTimestamp( TS_UNIX, $msgBlobMtime ) : 0; |
| 197 | + } |
196 | 198 | return $this->msgBlobMtime[$lang]; |
197 | 199 | } |
198 | 200 | |