3 * A foreign repository with a MediaWiki database accessible via the configured LBFactory
10 * A foreign repository with a MediaWiki database accessible via the configured LBFactory
14 class ForeignDBViaLBRepo
extends LocalRepo
{
15 var $wiki, $dbName, $tablePrefix;
16 var $fileFactory = array( 'ForeignDBFile', 'newFromTitle' );
17 var $fileFromRowFactory = array( 'ForeignDBFile', 'newFromRow' );
19 function __construct( $info ) {
20 parent
::__construct( $info );
21 $this->wiki
= $info['wiki'];
22 list( $this->dbName
, $this->tablePrefix
) = wfSplitWikiID( $this->wiki
);
23 $this->hasSharedCache
= $info['hasSharedCache'];
26 function getMasterDB() {
27 return wfGetDB( DB_MASTER
, array(), $this->wiki
);
30 function getSlaveDB() {
31 return wfGetDB( DB_SLAVE
, array(), $this->wiki
);
34 function hasSharedCache() {
35 return $this->hasSharedCache
;
39 * Get a key on the primary cache for this repository.
40 * Returns false if the repository's cache is not accessible at this site.
41 * The parameters are the parts of the key, as for wfMemcKey().
44 function getSharedCacheKey( /*...*/ ) {
45 if ( $this->hasSharedCache() ) {
46 $args = func_get_args();
47 array_unshift( $args, $this->wiki
);
48 return implode( ':', $args );
54 protected function assertWritableRepo() {
55 throw new MWException( get_class( $this ) . ': write operations are not supported.' );