Bug 23120. Make sure that all wikis sharing the same database use initialCapital
[lhc/web/wiklou.git] / includes / filerepo / ForeignDBRepo.php
1 <?php
2
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;
11
12 # Other stuff
13 var $dbConn;
14 var $fileFactory = array( 'ForeignDBFile', 'newFromTitle' );
15 var $fileFromRowFactory = array( 'ForeignDBFile', 'newFromRow' );
16
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'];
27 // This must not depend on per-wiki namespace configuration (bug 23120)
28 $this->initialCapital = true;
29 }
30
31 function getMasterDB() {
32 if ( !isset( $this->dbConn ) ) {
33 $class = 'Database' . ucfirst( $this->dbType );
34 $this->dbConn = new $class( $this->dbServer, $this->dbUser,
35 $this->dbPassword, $this->dbName, false, $this->dbFlags,
36 $this->tablePrefix );
37 }
38 return $this->dbConn;
39 }
40
41 function getSlaveDB() {
42 return $this->getMasterDB();
43 }
44
45 function hasSharedCache() {
46 return $this->hasSharedCache;
47 }
48
49 /**
50 * Get a key on the primary cache for this repository.
51 * Returns false if the repository's cache is not accessible at this site.
52 * The parameters are the parts of the key, as for wfMemcKey().
53 */
54 function getSharedCacheKey( /*...*/ ) {
55 if ( $this->hasSharedCache() ) {
56 $args = func_get_args();
57 array_unshift( $args, $this->dbName, $this->tablePrefix );
58 return call_user_func_array( 'wfForeignMemcKey', $args );
59 } else {
60 return false;
61 }
62 }
63
64 function store( $srcPath, $dstZone, $dstRel, $flags = 0 ) {
65 throw new MWException( get_class($this) . ': write operations are not supported' );
66 }
67 function publish( $srcPath, $dstRel, $archiveRel, $flags = 0 ) {
68 throw new MWException( get_class($this) . ': write operations are not supported' );
69 }
70 function deleteBatch( $sourceDestPairs ) {
71 throw new MWException( get_class($this) . ': write operations are not supported' );
72 }
73 }