dépôts
/
lhc
/
web
/
wiklou.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge "Make testFormatValueRestrictions() account for $wgArticlePath to avoid failures"
[lhc/web/wiklou.git]
/
includes
/
filerepo
/
ForeignDBViaLBRepo.php
diff --git
a/includes/filerepo/ForeignDBViaLBRepo.php
b/includes/filerepo/ForeignDBViaLBRepo.php
index
249cd27
..
ad6ec47
100644
(file)
--- a/
includes/filerepo/ForeignDBViaLBRepo.php
+++ b/
includes/filerepo/ForeignDBViaLBRepo.php
@@
-21,6
+21,10
@@
* @ingroup FileRepo
*/
* @ingroup FileRepo
*/
+use MediaWiki\MediaWikiServices;
+use Wikimedia\Rdbms\IDatabase;
+use Wikimedia\Rdbms\ILoadBalancer;
+
/**
* A foreign repository with a MediaWiki database accessible via the configured LBFactory
*
/**
* A foreign repository with a MediaWiki database accessible via the configured LBFactory
*
@@
-30,12
+34,6
@@
class ForeignDBViaLBRepo extends LocalRepo {
/** @var string */
protected $wiki;
/** @var string */
protected $wiki;
- /** @var string */
- protected $dbName;
-
- /** @var string */
- protected $tablePrefix;
-
/** @var array */
protected $fileFactory = [ ForeignDBFile::class, 'newFromTitle' ];
/** @var array */
protected $fileFactory = [ ForeignDBFile::class, 'newFromTitle' ];
@@
-51,7
+49,6
@@
class ForeignDBViaLBRepo extends LocalRepo {
function __construct( $info ) {
parent::__construct( $info );
$this->wiki = $info['wiki'];
function __construct( $info ) {
parent::__construct( $info );
$this->wiki = $info['wiki'];
- list( $this->dbName, $this->tablePrefix ) = wfSplitWikiID( $this->wiki );
$this->hasSharedCache = $info['hasSharedCache'];
}
$this->hasSharedCache = $info['hasSharedCache'];
}
@@
-59,14
+56,14
@@
class ForeignDBViaLBRepo extends LocalRepo {
* @return IDatabase
*/
function getMasterDB() {
* @return IDatabase
*/
function getMasterDB() {
- return
wfGetLB( $this->wiki
)->getConnectionRef( DB_MASTER, [], $this->wiki );
+ return
$this->getDBLoadBalancer(
)->getConnectionRef( DB_MASTER, [], $this->wiki );
}
/**
* @return IDatabase
*/
function getReplicaDB() {
}
/**
* @return IDatabase
*/
function getReplicaDB() {
- return
wfGetLB( $this->wiki
)->getConnectionRef( DB_REPLICA, [], $this->wiki );
+ return
$this->getDBLoadBalancer(
)->getConnectionRef( DB_REPLICA, [], $this->wiki );
}
/**
}
/**
@@
-74,10
+71,19
@@
class ForeignDBViaLBRepo extends LocalRepo {
*/
protected function getDBFactory() {
return function ( $index ) {
*/
protected function getDBFactory() {
return function ( $index ) {
- return
wfGetLB( $this->wiki
)->getConnectionRef( $index, [], $this->wiki );
+ return
$this->getDBLoadBalancer(
)->getConnectionRef( $index, [], $this->wiki );
};
}
};
}
+ /**
+ * @return ILoadBalancer
+ */
+ protected function getDBLoadBalancer() {
+ $lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
+
+ return $lbFactory->getMainLB( $this->wiki );
+ }
+
function hasSharedCache() {
return $this->hasSharedCache;
}
function hasSharedCache() {
return $this->hasSharedCache;
}