4 * A foreign repository with an accessible MediaWiki database
7 class ForeignDBRepo
extends LocalRepo
{
9 var $dbType, $dbServer, $dbUser, $dbPassword, $dbName, $dbFlags,
10 $tablePrefix, $hasSharedCache;
14 var $fileFactory = array( 'ForeignDBFile', 'newFromTitle' );
15 var $fileFromRowFactory = array( 'ForeignDBFile', 'newFromRow' );
17 function __construct( $info ) {
18 parent
::__construct( $info );
19 $this->dbType
= $info['dbType'];
20 $this->dbServer
= $info['dbServer'];
21 $this->dbUser
= $info['dbUser'];
22 $this->dbPassword
= $info['dbPassword'];
23 $this->dbName
= $info['dbName'];
24 $this->dbFlags
= $info['dbFlags'];
25 $this->tablePrefix
= $info['tablePrefix'];
26 $this->hasSharedCache
= $info['hasSharedCache'];
29 function getMasterDB() {
30 if ( !isset( $this->dbConn
) ) {
31 $class = 'Database' . ucfirst( $this->dbType
);
32 $this->dbConn
= new $class( $this->dbServer
, $this->dbUser
,
33 $this->dbPassword
, $this->dbName
, false, $this->dbFlags
,
39 function getSlaveDB() {
40 return $this->getMasterDB();
43 function hasSharedCache() {
44 return $this->hasSharedCache
;
48 * Get a key on the primary cache for this repository.
49 * Returns false if the repository's cache is not accessible at this site.
50 * The parameters are the parts of the key, as for wfMemcKey().
52 function getSharedCacheKey( /*...*/ ) {
53 if ( $this->hasSharedCache() ) {
54 $args = func_get_args();
55 array_unshift( $args, $this->dbName
, $this->tablePrefix
);
56 return call_user_func_array( 'wfForeignMemcKey', $args );
62 function store( $srcPath, $dstZone, $dstRel, $flags = 0 ) {
63 throw new MWException( get_class($this) . ': write operations are not supported' );
65 function publish( $srcPath, $dstRel, $archiveRel, $flags = 0 ) {
66 throw new MWException( get_class($this) . ': write operations are not supported' );
68 function deleteBatch( $fileMap ) {
69 throw new MWException( get_class($this) . ': write operations are not supported' );