MediaWiki REL1_31
ForeignDBViaLBRepo.php
Go to the documentation of this file.
1<?php
31 protected $wiki;
32
34 protected $dbName;
35
37 protected $tablePrefix;
38
40 protected $fileFactory = [ ForeignDBFile::class, 'newFromTitle' ];
41
43 protected $fileFromRowFactory = [ ForeignDBFile::class, 'newFromRow' ];
44
46 protected $hasSharedCache;
47
51 function __construct( $info ) {
52 parent::__construct( $info );
53 $this->wiki = $info['wiki'];
54 list( $this->dbName, $this->tablePrefix ) = wfSplitWikiID( $this->wiki );
55 $this->hasSharedCache = $info['hasSharedCache'];
56 }
57
61 function getMasterDB() {
62 return wfGetLB( $this->wiki )->getConnectionRef( DB_MASTER, [], $this->wiki );
63 }
64
68 function getReplicaDB() {
69 return wfGetLB( $this->wiki )->getConnectionRef( DB_REPLICA, [], $this->wiki );
70 }
71
75 protected function getDBFactory() {
76 return function ( $index ) {
77 return wfGetLB( $this->wiki )->getConnectionRef( $index, [], $this->wiki );
78 };
79 }
80
81 function hasSharedCache() {
83 }
84
91 function getSharedCacheKey( /*...*/ ) {
92 if ( $this->hasSharedCache() ) {
93 $args = func_get_args();
94 array_unshift( $args, $this->wiki );
95
96 return implode( ':', $args );
97 } else {
98 return false;
99 }
100 }
101
102 protected function assertWritableRepo() {
103 throw new MWException( static::class . ': write operations are not supported.' );
104 }
105
106 public function getInfo() {
107 return FileRepo::getInfo();
108 }
109}
wfGetLB( $wiki=false)
Get a load balancer object.
wfSplitWikiID( $wiki)
Split a wiki ID into DB name and table prefix.
if( $line===false) $args
Definition cdb.php:64
getInfo()
Return information about the repository.
A foreign repository with a MediaWiki database accessible via the configured LBFactory.
getInfo()
Return information about the repository.
getSharedCacheKey()
Get a key on the primary cache for this repository.
assertWritableRepo()
Throw an exception if this repo is read-only by design.
A repository that stores files in the local filesystem and registers them in the wiki's own database.
Definition LocalRepo.php:35
MediaWiki exception.
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
Definition deferred.txt:11
const DB_REPLICA
Definition defines.php:25
const DB_MASTER
Definition defines.php:29