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\Category\Category;
|
||||||
use MediaWiki\Linker\LinkTarget;
|
use MediaWiki\Linker\LinkTarget;
|
||||||
use Wikimedia\Rdbms\ILoadBalancer;
|
use Wikimedia\Rdbms\IConnectionProvider;
|
||||||
use Wikimedia\Rdbms\IResultWrapper;
|
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 */
|
/** @var (?Category)[] Keys are category database names, values are either a Category object or null */
|
||||||
private array $cache = [];
|
private array $cache = [];
|
||||||
|
|
||||||
private ILoadBalancer $loadBalancer;
|
private IConnectionProvider $dbProvider;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
ILoadBalancer $loadBalancer
|
IConnectionProvider $dbProvider
|
||||||
) {
|
) {
|
||||||
$this->loadBalancer = $loadBalancer;
|
$this->dbProvider = $dbProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -78,7 +78,7 @@ class CategoryCache {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$rows = $this->loadBalancer->getConnection( ILoadBalancer::DB_REPLICA )
|
$rows = $this->dbProvider->getReplicaDatabase()
|
||||||
->newSelectQueryBuilder()
|
->newSelectQueryBuilder()
|
||||||
->select( [ 'cat_id', 'cat_title', 'cat_pages', 'cat_subcats', 'cat_files' ] )
|
->select( [ 'cat_id', 'cat_title', 'cat_pages', 'cat_subcats', 'cat_files' ] )
|
||||||
->from( 'category' )
|
->from( 'category' )
|
||||||
|
|
|
@ -33,7 +33,7 @@ use MediaWiki\MediaWikiServices;
|
||||||
return [
|
return [
|
||||||
'CategoryTree.CategoryCache' => static function ( MediaWikiServices $services ): CategoryCache {
|
'CategoryTree.CategoryCache' => static function ( MediaWikiServices $services ): CategoryCache {
|
||||||
return new CategoryCache(
|
return new CategoryCache(
|
||||||
$services->getDBLoadBalancer()
|
$services->getConnectionProvider()
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
|
@ -24,7 +24,7 @@ use MediaWiki\Category\Category;
|
||||||
use MediaWiki\Extension\CategoryTree\CategoryCache;
|
use MediaWiki\Extension\CategoryTree\CategoryCache;
|
||||||
use MediaWiki\Title\TitleValue;
|
use MediaWiki\Title\TitleValue;
|
||||||
use MediaWikiIntegrationTestCase;
|
use MediaWikiIntegrationTestCase;
|
||||||
use Wikimedia\Rdbms\ILoadBalancer;
|
use Wikimedia\Rdbms\IConnectionProvider;
|
||||||
use Wikimedia\TestingAccessWrapper;
|
use Wikimedia\TestingAccessWrapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -35,7 +35,7 @@ class CategoryCacheTest extends MediaWikiIntegrationTestCase {
|
||||||
|
|
||||||
public function testConstruct() {
|
public function testConstruct() {
|
||||||
new CategoryCache(
|
new CategoryCache(
|
||||||
$this->createMock( ILoadBalancer::class )
|
$this->createMock( IConnectionProvider::class )
|
||||||
);
|
);
|
||||||
$this->addToAssertionCount( 1 );
|
$this->addToAssertionCount( 1 );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue