X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;ds=sidebyside;f=includes%2Ffilerepo%2FForeignDBViaLBRepo.php;h=302b194a2cda98403568248f778cd08e02e39ecb;hb=478a58f63101f2b47d18a618296b5e7970fa3f24;hp=bcd253fb4a6b742dae7046b93e1b0dbaf2db8d84;hpb=85ac1b5d7c7ca50a93f2d16639cdde2f46bc133e;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/filerepo/ForeignDBViaLBRepo.php b/includes/filerepo/ForeignDBViaLBRepo.php index bcd253fb4a..302b194a2c 100644 --- a/includes/filerepo/ForeignDBViaLBRepo.php +++ b/includes/filerepo/ForeignDBViaLBRepo.php @@ -21,6 +21,10 @@ * @ingroup FileRepo */ +use MediaWiki\MediaWikiServices; +use Wikimedia\Rdbms\IDatabase; +use Wikimedia\Rdbms\LoadBalancer; + /** * A foreign repository with a MediaWiki database accessible via the configured LBFactory * @@ -37,10 +41,10 @@ class ForeignDBViaLBRepo extends LocalRepo { protected $tablePrefix; /** @var array */ - protected $fileFactory = [ 'ForeignDBFile', 'newFromTitle' ]; + protected $fileFactory = [ ForeignDBFile::class, 'newFromTitle' ]; /** @var array */ - protected $fileFromRowFactory = [ 'ForeignDBFile', 'newFromRow' ]; + protected $fileFromRowFactory = [ ForeignDBFile::class, 'newFromRow' ]; /** @var bool */ protected $hasSharedCache; @@ -59,14 +63,14 @@ class ForeignDBViaLBRepo extends LocalRepo { * @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 wfGetLB( $this->wiki )->getConnectionRef( DB_REPLICA, [], $this->wiki ); + return $this->getDBLoadBalancer()->getConnectionRef( DB_REPLICA, [], $this->wiki ); } /** @@ -74,10 +78,18 @@ class ForeignDBViaLBRepo extends LocalRepo { */ protected function getDBFactory() { return function ( $index ) { - return wfGetLB( $this->wiki )->getConnectionRef( $index, [], $this->wiki ); + return $this->getDBLoadBalancer()->getConnectionRef( $index, [], $this->wiki ); }; } + /** + * @return LoadBalancer + */ + protected function getDBLoadBalancer() { + $lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory(); + return $lbFactory->getMainLB( $this->wiki ); + } + function hasSharedCache() { return $this->hasSharedCache; }