MediaWiki REL1_40
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 getReplicaDB() {
51 return $this->getDBLoadBalancer()->getConnectionRef( DB_REPLICA, [], $this->dbDomain );
52 }
53
57 protected function getDBFactory() {
58 return function ( $index ) {
59 return $this->getDBLoadBalancer()->getConnectionRef( $index, [], $this->dbDomain );
60 };
61 }
62
66 protected function getDBLoadBalancer() {
67 $lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
68
69 return $lbFactory->getMainLB( $this->dbDomain );
70 }
71
72 protected function assertWritableRepo() {
73 throw new MWException( static::class . ': write operations are not supported.' );
74 }
75
76 public function getInfo() {
77 return FileRepo::getInfo();
78 }
79}
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.
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:41
MediaWiki exception.
Service locator for MediaWiki core services.
This class is a delegate to ILBFactory for a given database cluster.
const DB_REPLICA
Definition defines.php:26
const DB_PRIMARY
Definition defines.php:28