Index: trunk/phase3/includes/resourceloader/ResourceLoaderWikiModule.php |
— | — | @@ -51,13 +51,14 @@ |
52 | 52 | |
53 | 53 | /** |
54 | 54 | * Get the Database object used in getTitleMTimes(). Defaults to the local slave DB |
55 | | - * but subclasses may want to override this to return a remote DB object. |
| 55 | + * but subclasses may want to override this to return a remote DB object, or to return |
| 56 | + * null if getTitleMTimes() shouldn't access the DB at all. |
56 | 57 | * |
57 | 58 | * NOTE: This ONLY works for getTitleMTimes() and getModifiedTime(), NOT FOR ANYTHING ELSE. |
58 | 59 | * In particular, it doesn't work for getting the content of JS and CSS pages. That functionality |
59 | 60 | * will use the local DB irrespective of the return value of this method. |
60 | 61 | * |
61 | | - * @return DatabaseBase |
| 62 | + * @return DatabaseBase|null |
62 | 63 | */ |
63 | 64 | protected function getDB() { |
64 | 65 | return wfGetDB( DB_SLAVE ); |
— | — | @@ -174,6 +175,12 @@ |
175 | 176 | * @return array( prefixed DB key => UNIX timestamp ), nonexistent titles are dropped |
176 | 177 | */ |
177 | 178 | protected function getTitleMtimes( ResourceLoaderContext $context ) { |
| 179 | + $dbr = $this->getDB(); |
| 180 | + if ( !$dbr ) { |
| 181 | + // We're dealing with a subclass that doesn't have a DB |
| 182 | + return array(); |
| 183 | + } |
| 184 | + |
178 | 185 | $hash = $context->getHash(); |
179 | 186 | if ( isset( $this->titleMtimes[$hash] ) ) { |
180 | 187 | return $this->titleMtimes[$hash]; |
— | — | @@ -186,7 +193,6 @@ |
187 | 194 | } |
188 | 195 | |
189 | 196 | if ( !$batch->isEmpty() ) { |
190 | | - $dbr = $this->getDB(); |
191 | 197 | $res = $dbr->select( 'page', |
192 | 198 | array( 'page_namespace', 'page_title', 'page_touched' ), |
193 | 199 | $batch->constructSet( 'page', $dbr ), |