MediaWiki  REL1_24
ForeignDBViaLBRepo.php
Go to the documentation of this file.
00001 <?php
00029 class ForeignDBViaLBRepo extends LocalRepo {
00031     protected $wiki;
00032 
00034     protected $dbName;
00035 
00037     protected $tablePrefix;
00038 
00040     protected $fileFactory = array( 'ForeignDBFile', 'newFromTitle' );
00041 
00043     protected $fileFromRowFactory = array( 'ForeignDBFile', 'newFromRow' );
00044 
00048     function __construct( $info ) {
00049         parent::__construct( $info );
00050         $this->wiki = $info['wiki'];
00051         list( $this->dbName, $this->tablePrefix ) = wfSplitWikiID( $this->wiki );
00052         $this->hasSharedCache = $info['hasSharedCache'];
00053     }
00054 
00058     function getMasterDB() {
00059         return wfGetDB( DB_MASTER, array(), $this->wiki );
00060     }
00061 
00065     function getSlaveDB() {
00066         return wfGetDB( DB_SLAVE, array(), $this->wiki );
00067     }
00068 
00069     function hasSharedCache() {
00070         return $this->hasSharedCache;
00071     }
00072 
00079     function getSharedCacheKey( /*...*/ ) {
00080         if ( $this->hasSharedCache() ) {
00081             $args = func_get_args();
00082             array_unshift( $args, $this->wiki );
00083 
00084             return implode( ':', $args );
00085         } else {
00086             return false;
00087         }
00088     }
00089 
00090     protected function assertWritableRepo() {
00091         throw new MWException( get_class( $this ) . ': write operations are not supported.' );
00092     }
00093 
00094     public function getInfo() {
00095         return FileRepo::getInfo();
00096     }
00097 }