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