"<p id="userloginlink"><p>Don't have an account" is illegal xhtml
[mediawiki.git] / includes / filerepo / ForeignDBRepo.php
blobdf3fde90b541004ad9a28966d9649f48b17819a0
1 <?php
3 /**
4 * A foreign repository with an accessible MediaWiki database
5 * @ingroup FileRepo
6 */
7 class ForeignDBRepo extends LocalRepo {
8 # Settings
9 var $dbType, $dbServer, $dbUser, $dbPassword, $dbName, $dbFlags,
10 $tablePrefix, $hasSharedCache;
12 # Other stuff
13 var $dbConn;
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,
34 $this->tablePrefix );
36 return $this->dbConn;
39 function getSlaveDB() {
40 return $this->getMasterDB();
43 function hasSharedCache() {
44 return $this->hasSharedCache;
47 /**
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 );
57 } else {
58 return false;
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( $sourceDestPairs ) {
69 throw new MWException( get_class($this) . ': write operations are not supported' );