From 641081d3416321991a276070bd98333e2d2e139d Mon Sep 17 00:00:00 2001 From: Roan Kattouw Date: Tue, 2 Aug 2011 15:47:30 +0000 Subject: [PATCH] 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. --- .../resourceloader/ResourceLoaderWikiModule.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/includes/resourceloader/ResourceLoaderWikiModule.php b/includes/resourceloader/ResourceLoaderWikiModule.php index 83fa294096..c9e7e56ed3 100644 --- a/includes/resourceloader/ResourceLoaderWikiModule.php +++ b/includes/resourceloader/ResourceLoaderWikiModule.php @@ -44,6 +44,20 @@ abstract class ResourceLoaderWikiModule extends ResourceLoaderModule { abstract protected function getPages( ResourceLoaderContext $context ); /* Protected Methods */ + + /** + * Get the Database object used in getTitleMTimes(). Defaults to the local slave DB + * but subclasses may want to override this to return a remote DB object. + * + * NOTE: This ONLY works for getTitleMTimes() and getModifiedTime(), NOT FOR ANYTHING ELSE. + * In particular, it doesn't work for getting the content of JS and CSS pages. That functionality + * will use the local DB irrespective of the return value of this method. + * + * @return DatabaseBase + */ + protected function getDB() { + return wfGetDB( DB_SLAVE ); + } /** * @param $title Title @@ -168,7 +182,7 @@ abstract class ResourceLoaderWikiModule extends ResourceLoaderModule { } if ( !$batch->isEmpty() ) { - $dbr = wfGetDB( DB_SLAVE ); + $dbr = $this->getDB(); $res = $dbr->select( 'page', array( 'page_namespace', 'page_title', 'page_touched' ), $batch->constructSet( 'page', $dbr ), -- 2.20.1