MediaWiki REL1_39
ForeignDBViaLBRepo.php
Go to the documentation of this file.
1<?php
23
31 protected $fileFactory = [ ForeignDBFile::class, 'newFromTitle' ];
32
34 protected $fileFromRowFactory = [ ForeignDBFile::class, 'newFromRow' ];
35
39 public function __construct( $info ) {
40 parent::__construct( $info );
41 '@phan-var array $info';
42 $this->dbDomain = $info['wiki'];
43 $this->hasAccessibleSharedCache = $info['hasSharedCache'];
44 }
45
46 public function getPrimaryDB() {
47 return $this->getDBLoadBalancer()->getConnectionRef( DB_PRIMARY, [], $this->dbDomain );
48 }
49
50 public function getMasterDB() {
51 wfDeprecated( __METHOD__, '1.37' );
52 return $this->getPrimaryDB();
53 }
54
55 public function getReplicaDB() {
56 return $this->getDBLoadBalancer()->getConnectionRef( DB_REPLICA, [], $this->dbDomain );
57 }
58
62 protected function getDBFactory() {
63 return function ( $index ) {
64 return $this->getDBLoadBalancer()->getConnectionRef( $index, [], $this->dbDomain );
65 };
66 }
67
71 protected function getDBLoadBalancer() {
72 $lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
73
74 return $lbFactory->getMainLB( $this->dbDomain );
75 }
76
77 protected function assertWritableRepo() {
78 throw new MWException( static::class . ': write operations are not supported.' );
79 }
80
81 public function getInfo() {
82 return FileRepo::getInfo();
83 }
84}
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Logs a warning that a deprecated feature was used.
getInfo()
Return information about the repository.
A foreign repository with a MediaWiki database accessible via the configured LBFactory.
getInfo()
Return information about the repository.
getPrimaryDB()
Get a connection to the primary DB.
getMasterDB()
Get a connection to the primary DB.
assertWritableRepo()
Throw an exception if this repo is read-only by design.
getReplicaDB()
Get a connection to the replica DB.
Local repository that stores files in the local filesystem and registers them in the wiki's own datab...
Definition LocalRepo.php:39
MediaWiki exception.
Service locator for MediaWiki core services.
Create and track the database connections and transactions for a given database cluster.
const DB_REPLICA
Definition defines.php:26
const DB_PRIMARY
Definition defines.php:28