Use IConnectionProvider instead of ILoadBalancer

Change-Id: Id1071e0a61030c2ddd01fecebf6bf8a99c5948e0
This commit is contained in:
Fomafix 2024-09-04 13:27:15 +00:00
parent be2605a0d5
commit 58afeaf93c
3 changed files with 8 additions and 8 deletions

View file

@ -22,7 +22,7 @@ namespace MediaWiki\Extension\CategoryTree;
use MediaWiki\Category\Category;
use MediaWiki\Linker\LinkTarget;
use Wikimedia\Rdbms\ILoadBalancer;
use Wikimedia\Rdbms\IConnectionProvider;
use Wikimedia\Rdbms\IResultWrapper;
/**
@ -32,12 +32,12 @@ class CategoryCache {
/** @var (?Category)[] Keys are category database names, values are either a Category object or null */
private array $cache = [];
private ILoadBalancer $loadBalancer;
private IConnectionProvider $dbProvider;
public function __construct(
ILoadBalancer $loadBalancer
IConnectionProvider $dbProvider
) {
$this->loadBalancer = $loadBalancer;
$this->dbProvider = $dbProvider;
}
/**
@ -78,7 +78,7 @@ class CategoryCache {
return;
}
$rows = $this->loadBalancer->getConnection( ILoadBalancer::DB_REPLICA )
$rows = $this->dbProvider->getReplicaDatabase()
->newSelectQueryBuilder()
->select( [ 'cat_id', 'cat_title', 'cat_pages', 'cat_subcats', 'cat_files' ] )
->from( 'category' )

View file

@ -33,7 +33,7 @@ use MediaWiki\MediaWikiServices;
return [
'CategoryTree.CategoryCache' => static function ( MediaWikiServices $services ): CategoryCache {
return new CategoryCache(
$services->getDBLoadBalancer()
$services->getConnectionProvider()
);
},
];

View file

@ -24,7 +24,7 @@ use MediaWiki\Category\Category;
use MediaWiki\Extension\CategoryTree\CategoryCache;
use MediaWiki\Title\TitleValue;
use MediaWikiIntegrationTestCase;
use Wikimedia\Rdbms\ILoadBalancer;
use Wikimedia\Rdbms\IConnectionProvider;
use Wikimedia\TestingAccessWrapper;
/**
@ -35,7 +35,7 @@ class CategoryCacheTest extends MediaWikiIntegrationTestCase {
public function testConstruct() {
new CategoryCache(
$this->createMock( ILoadBalancer::class )
$this->createMock( IConnectionProvider::class )
);
$this->addToAssertionCount( 1 );
}