* @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
*
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;
* @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 );
}
/**
*/
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;
}