MediaWiki REL1_37
ForeignDBViaLBRepo.php
Go to the documentation of this file.
1<?php
26
34 protected $fileFactory = [ ForeignDBFile::class, 'newFromTitle' ];
35
37 protected $fileFromRowFactory = [ ForeignDBFile::class, 'newFromRow' ];
38
42 public function __construct( $info ) {
43 parent::__construct( $info );
44 '@phan-var array $info';
45 $this->dbDomain = $info['wiki'];
46 $this->hasAccessibleSharedCache = $info['hasSharedCache'];
47 }
48
49 public function getPrimaryDB() {
50 return $this->getDBLoadBalancer()->getConnectionRef( DB_PRIMARY, [], $this->dbDomain );
51 }
52
53 public function getMasterDB() {
54 wfDeprecated( __METHOD__, '1.37' );
55 return $this->getPrimaryDB();
56 }
57
58 public function getReplicaDB() {
59 return $this->getDBLoadBalancer()->getConnectionRef( DB_REPLICA, [], $this->dbDomain );
60 }
61
65 protected function getDBFactory() {
66 return function ( $index ) {
67 return $this->getDBLoadBalancer()->getConnectionRef( $index, [], $this->dbDomain );
68 };
69 }
70
74 protected function getDBLoadBalancer() {
75 $lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
76
77 return $lbFactory->getMainLB( $this->dbDomain );
78 }
79
80 protected function assertWritableRepo() {
81 throw new MWException( static::class . ': write operations are not supported.' );
82 }
83
84 public function getInfo() {
85 return FileRepo::getInfo();
86 }
87}
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.
A repository that stores files in the local filesystem and registers them in the wiki's own database.
Definition LocalRepo.php:41
MediaWiki exception.
MediaWikiServices is the service locator for the application scope of MediaWiki.
Database cluster connection, tracking, load balancing, and transaction manager interface.
const DB_REPLICA
Definition defines.php:25
const DB_PRIMARY
Definition defines.php:27