mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/CategoryTree
synced 2024-11-27 09:43:06 +00:00
Use IConnectionProvider instead of ILoadBalancer
Change-Id: Id1071e0a61030c2ddd01fecebf6bf8a99c5948e0
This commit is contained in:
parent
be2605a0d5
commit
58afeaf93c
|
@ -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' )
|
||||
|
|
|
@ -33,7 +33,7 @@ use MediaWiki\MediaWikiServices;
|
|||
return [
|
||||
'CategoryTree.CategoryCache' => static function ( MediaWikiServices $services ): CategoryCache {
|
||||
return new CategoryCache(
|
||||
$services->getDBLoadBalancer()
|
||||
$services->getConnectionProvider()
|
||||
);
|
||||
},
|
||||
];
|
||||
|
|
|
@ -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 );
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue