From 9d4ccf0db4f1cf537a5eb019d6c846217eb4e0d1 Mon Sep 17 00:00:00 2001 From: Amir Sarabadani Date: Wed, 28 Feb 2024 13:55:05 +0100 Subject: [PATCH] Switch to ICP and stop using DBAccessObjectUtils::getDBOptions() We are getting rid of this Bug: T354194 Change-Id: I70c613993647f77259ef0ccf7570e3560b66ef56 --- ServiceWiring.php | 4 ++-- includes/EchoCoreThanksPresentationModel.php | 2 +- includes/ThanksQueryHelper.php | 14 +++++--------- 3 files changed, 8 insertions(+), 12 deletions(-) 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()