Merge "Use IConnectionProvider instead of ILoadBalancer"

This commit is contained in:
jenkins-bot 2024-09-10 16:41:38 +00:00 committed by Gerrit Code Review
commit b0d8410812
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 );
}