r93760 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r93759‎ | r93760 | r93761 >
Date:15:47, 2 August 2011
Author:catrope
Status:ok
Tags:
Comment:
Factor out obtaining the database object in ResourceLoaderWikiModule into a getDB() method that can be overridden by subclasses. This is needed for the Gadgets extension in the RL2 branch, which subclasses ResourceLoaderWikiModule to create modules for foreign wiki pages.
Modified paths:
  • /trunk/phase3/includes/resourceloader/ResourceLoaderWikiModule.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/resourceloader/ResourceLoaderWikiModule.php
@@ -44,6 +44,20 @@
4545 abstract protected function getPages( ResourceLoaderContext $context );
4646
4747 /* Protected Methods */
 48+
 49+ /**
 50+ * Get the Database object used in getTitleMTimes(). Defaults to the local slave DB
 51+ * but subclasses may want to override this to return a remote DB object.
 52+ *
 53+ * NOTE: This ONLY works for getTitleMTimes() and getModifiedTime(), NOT FOR ANYTHING ELSE.
 54+ * In particular, it doesn't work for getting the content of JS and CSS pages. That functionality
 55+ * will use the local DB irrespective of the return value of this method.
 56+ *
 57+ * @return DatabaseBase
 58+ */
 59+ protected function getDB() {
 60+ return wfGetDB( DB_SLAVE );
 61+ }
4862
4963 /**
5064 * @param $title Title
@@ -168,7 +182,7 @@
169183 }
170184
171185 if ( !$batch->isEmpty() ) {
172 - $dbr = wfGetDB( DB_SLAVE );
 186+ $dbr = $this->getDB();
173187 $res = $dbr->select( 'page',
174188 array( 'page_namespace', 'page_title', 'page_touched' ),
175189 $batch->constructSet( 'page', $dbr ),

Follow-up revisions

RevisionCommit summaryAuthorDate
r101628Allow overrides of ResourceLoaderWikiModule::getDB() (introduced in r93760) t...catrope15:04, 2 November 2011

Status & tagging log