MediaWiki REL1_35
ForeignDBViaLBRepo.php
Go to the documentation of this file.
1<?php
26
34 protected $wiki;
35
37 protected $fileFactory = [ ForeignDBFile::class, 'newFromTitle' ];
38
40 protected $fileFromRowFactory = [ ForeignDBFile::class, 'newFromRow' ];
41
43 protected $hasSharedCache;
44
48 public function __construct( $info ) {
49 parent::__construct( $info );
50 '@phan-var array $info';
51 $this->wiki = $info['wiki'];
52 $this->hasSharedCache = $info['hasSharedCache'];
53 }
54
55 public function getMasterDB() {
56 return $this->getDBLoadBalancer()->getConnectionRef( DB_MASTER, [], $this->wiki );
57 }
58
59 public function getReplicaDB() {
60 return $this->getDBLoadBalancer()->getConnectionRef( DB_REPLICA, [], $this->wiki );
61 }
62
66 protected function getDBFactory() {
67 return function ( $index ) {
68 return $this->getDBLoadBalancer()->getConnectionRef( $index, [], $this->wiki );
69 };
70 }
71
75 protected function getDBLoadBalancer() {
76 $lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
77
78 return $lbFactory->getMainLB( $this->wiki );
79 }
80
81 private function hasSharedCache() {
83 }
84
85 public function getSharedCacheKey( ...$args ) {
86 if ( $this->hasSharedCache() ) {
87 return $this->wanCache->makeGlobalKey( $this->wiki, ...$args );
88 } else {
89 return false;
90 }
91 }
92
93 protected function assertWritableRepo() {
94 throw new MWException( static::class . ': write operations are not supported.' );
95 }
96
97 public function getInfo() {
98 return FileRepo::getInfo();
99 }
100}
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(... $args)
Get a key on the primary cache for this repository.
getMasterDB()
Get a connection to the master 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:37
MediaWiki exception.
MediaWikiServices is the service locator for the application scope of MediaWiki.
Database cluster connection, tracking, load balancing, and transaction manager interface.
if( $line===false) $args
Definition mcc.php:124
const DB_REPLICA
Definition defines.php:25
const DB_MASTER
Definition defines.php:29