moving SpecialUploadMogile.php from phase3/includes/specials to extensions/MogileClie...
[lhc/web/wiklou.git] / includes / filerepo / ForeignDBViaLBRepo.php
1 <?php
2
3 /**
4 * A foreign repository with a MediaWiki database accessible via the configured LBFactory
5 * @ingroup FileRepo
6 */
7 class ForeignDBViaLBRepo extends LocalRepo {
8 var $wiki, $dbName, $tablePrefix;
9 var $fileFactory = array( 'ForeignDBFile', 'newFromTitle' );
10 var $fileFromRowFactory = array( 'ForeignDBFile', 'newFromRow' );
11
12 function __construct( $info ) {
13 parent::__construct( $info );
14 $this->wiki = $info['wiki'];
15 list( $this->dbName, $this->tablePrefix ) = wfSplitWikiID( $this->wiki );
16 $this->hasSharedCache = $info['hasSharedCache'];
17 }
18
19 function getMasterDB() {
20 return wfGetDB( DB_MASTER, array(), $this->wiki );
21 }
22
23 function getSlaveDB() {
24 return wfGetDB( DB_SLAVE, array(), $this->wiki );
25 }
26 function hasSharedCache() {
27 return $this->hasSharedCache;
28 }
29
30 /**
31 * Get a key on the primary cache for this repository.
32 * Returns false if the repository's cache is not accessible at this site.
33 * The parameters are the parts of the key, as for wfMemcKey().
34 */
35 function getSharedCacheKey( /*...*/ ) {
36 if ( $this->hasSharedCache() ) {
37 $args = func_get_args();
38 array_unshift( $args, $this->wiki );
39 return implode( ':', $args );
40 } else {
41 return false;
42 }
43 }
44
45 function store( $srcPath, $dstZone, $dstRel, $flags = 0 ) {
46 throw new MWException( get_class($this) . ': write operations are not supported' );
47 }
48 function publish( $srcPath, $dstRel, $archiveRel, $flags = 0 ) {
49 throw new MWException( get_class($this) . ': write operations are not supported' );
50 }
51 function deleteBatch( $fileMap ) {
52 throw new MWException( get_class($this) . ': write operations are not supported' );
53 }
54 }