http://www.mediawiki.org/wiki/Special:Code/MediaWiki/93760
Revision: 93760 Author: catrope Date: 2011-08-02 15:47:30 +0000 (Tue, 02 Aug 2011) Log Message: ----------- 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: trunk/phase3/includes/resourceloader/ResourceLoaderWikiModule.php =================================================================== --- trunk/phase3/includes/resourceloader/ResourceLoaderWikiModule.php 2011-08-02 15:40:27 UTC (rev 93759) +++ trunk/phase3/includes/resourceloader/ResourceLoaderWikiModule.php 2011-08-02 15:47:30 UTC (rev 93760) @@ -44,6 +44,20 @@ 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 @@ } 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 ), _______________________________________________ MediaWiki-CVS mailing list MediaWiki-CVS@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs