r101628 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r101627‎ | r101628 | r101629 >
Date:15:04, 2 November 2011
Author:catrope
Status:ok
Tags:
Comment:
Allow overrides of ResourceLoaderWikiModule::getDB() (introduced in r93760) to return null, needed for ForeignAPIGadgetRepo support (introduced in r101627)
Modified paths:
  • /trunk/phase3/includes/resourceloader/ResourceLoaderWikiModule.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/resourceloader/ResourceLoaderWikiModule.php
@@ -51,13 +51,14 @@
5252
5353 /**
5454 * 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.
5657 *
5758 * NOTE: This ONLY works for getTitleMTimes() and getModifiedTime(), NOT FOR ANYTHING ELSE.
5859 * In particular, it doesn't work for getting the content of JS and CSS pages. That functionality
5960 * will use the local DB irrespective of the return value of this method.
6061 *
61 - * @return DatabaseBase
 62+ * @return DatabaseBase|null
6263 */
6364 protected function getDB() {
6465 return wfGetDB( DB_SLAVE );
@@ -174,6 +175,12 @@
175176 * @return array( prefixed DB key => UNIX timestamp ), nonexistent titles are dropped
176177 */
177178 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+
178185 $hash = $context->getHash();
179186 if ( isset( $this->titleMtimes[$hash] ) ) {
180187 return $this->titleMtimes[$hash];
@@ -186,7 +193,6 @@
187194 }
188195
189196 if ( !$batch->isEmpty() ) {
190 - $dbr = $this->getDB();
191197 $res = $dbr->select( 'page',
192198 array( 'page_namespace', 'page_title', 'page_touched' ),
193199 $batch->constructSet( 'page', $dbr ),

Follow-up revisions

RevisionCommit summaryAuthorDate
r102788[RL2] Remove obsolete TODO, was fixed in r101628catrope15:15, 11 November 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r93760Factor out obtaining the database object in ResourceLoaderWikiModule into a g...catrope15:47, 2 August 2011
r101627[RL2] Add ForeignAPIGadgetRepo. Tested and workingcatrope15:02, 2 November 2011

Status & tagging log