diff --git a/ServiceWiring.php b/ServiceWiring.php index 244ec5e2..7bd4ac3f 100644 --- a/ServiceWiring.php +++ b/ServiceWiring.php @@ -11,12 +11,12 @@ return [ ): ThanksQueryHelper { return new ThanksQueryHelper( $services->getTitleFactory(), - $services->getDBLoadBalancer() + $services->getConnectionProvider() ); }, 'ThanksLogStore' => static function ( MediaWikiServices $services ): LogStore { return new LogStore( - $services->getDBLoadBalancerFactory(), + $services->getConnectionProvider(), $services->getActorNormalization(), new ServiceOptions( LogStore::CONSTRUCTOR_OPTIONS, diff --git a/includes/EchoCoreThanksPresentationModel.php b/includes/EchoCoreThanksPresentationModel.php index e0d3e880..26565e6a 100644 --- a/includes/EchoCoreThanksPresentationModel.php +++ b/includes/EchoCoreThanksPresentationModel.php @@ -162,7 +162,7 @@ class EchoCoreThanksPresentationModel extends EchoEventPresentationModel { if ( !$logId ) { $this->logEntry = false; } else { - $dbr = MediaWikiServices::getInstance()->getDBLoadBalancerFactory()->getReplicaDatabase(); + $dbr = MediaWikiServices::getInstance()->getConnectionProvider()->getReplicaDatabase(); $this->logEntry = DatabaseLogEntry::newFromId( $logId, $dbr ) ?: false; } return $this->logEntry; diff --git a/includes/ThanksQueryHelper.php b/includes/ThanksQueryHelper.php index 06a11cc7..c2758088 100644 --- a/includes/ThanksQueryHelper.php +++ b/includes/ThanksQueryHelper.php @@ -5,20 +5,18 @@ use DBAccessObjectUtils; use IDBAccessObject; use MediaWiki\Title\TitleFactory; use MediaWiki\User\UserIdentity; -use Wikimedia\Rdbms\ILoadBalancer; +use Wikimedia\Rdbms\IConnectionProvider; /** * Query module */ class ThanksQueryHelper { - /** @var TitleFactory */ private TitleFactory $titleFactory; - /** @var ILoadBalancer */ - private ILoadBalancer $loadBalancer; + private IConnectionProvider $dbProvider; - public function __construct( TitleFactory $titleFactory, ILoadBalancer $loadBalancer ) { + public function __construct( TitleFactory $titleFactory, IConnectionProvider $dbProvider ) { $this->titleFactory = $titleFactory; - $this->loadBalancer = $loadBalancer; + $this->dbProvider = $dbProvider; } /** @@ -36,9 +34,7 @@ class ThanksQueryHelper { int $limit = 1000, int $flags = IDBAccessObject::READ_NORMAL ): int { - $loadBalancer = $this->loadBalancer; - list( $index, $options ) = DBAccessObjectUtils::getDBOptions( $flags ); - $db = $loadBalancer->getConnection( $index ); + $db = DBAccessObjectUtils::getDBFromRecency( $this->dbProvider, $flags ); $userPage = $this->titleFactory->newFromText( $userIdentity->getName(), NS_USER ); $logTitle = $userPage->getDBkey(); return $db->newSelectQueryBuilder()