mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/CategoryTree
synced 2024-11-27 17:51:00 +00:00
Replace deprecated wfGetDB( DB_REPLICA )
Bug: T330641 Change-Id: Ic2dc694bbb29c3ff315f2be32c24ee6995f9b964
This commit is contained in:
parent
449b72d9e4
commit
b2ef67d9c8
|
@ -24,6 +24,7 @@
|
||||||
"class": "MediaWiki\\Extension\\CategoryTree\\ApiCategoryTree",
|
"class": "MediaWiki\\Extension\\CategoryTree\\ApiCategoryTree",
|
||||||
"services": [
|
"services": [
|
||||||
"ConfigFactory",
|
"ConfigFactory",
|
||||||
|
"DBLoadBalancerFactory",
|
||||||
"LanguageConverterFactory",
|
"LanguageConverterFactory",
|
||||||
"MainWANObjectCache"
|
"MainWANObjectCache"
|
||||||
]
|
]
|
||||||
|
|
|
@ -11,6 +11,7 @@ use MediaWiki\Languages\LanguageConverterFactory;
|
||||||
use MediaWiki\Title\Title;
|
use MediaWiki\Title\Title;
|
||||||
use WANObjectCache;
|
use WANObjectCache;
|
||||||
use Wikimedia\ParamValidator\ParamValidator;
|
use Wikimedia\ParamValidator\ParamValidator;
|
||||||
|
use Wikimedia\Rdbms\IConnectionProvider;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
@ -36,6 +37,9 @@ class ApiCategoryTree extends ApiBase {
|
||||||
/** @var LanguageConverterFactory */
|
/** @var LanguageConverterFactory */
|
||||||
private $languageConverterFactory;
|
private $languageConverterFactory;
|
||||||
|
|
||||||
|
/** @var IConnectionProvider */
|
||||||
|
private $dbProvider;
|
||||||
|
|
||||||
/** @var WANObjectCache */
|
/** @var WANObjectCache */
|
||||||
private $wanCache;
|
private $wanCache;
|
||||||
|
|
||||||
|
@ -43,6 +47,7 @@ class ApiCategoryTree extends ApiBase {
|
||||||
* @param ApiMain $main
|
* @param ApiMain $main
|
||||||
* @param string $action
|
* @param string $action
|
||||||
* @param ConfigFactory $configFactory
|
* @param ConfigFactory $configFactory
|
||||||
|
* @param IConnectionProvider $dbProvider
|
||||||
* @param LanguageConverterFactory $languageConverterFactory
|
* @param LanguageConverterFactory $languageConverterFactory
|
||||||
* @param WANObjectCache $wanCache
|
* @param WANObjectCache $wanCache
|
||||||
*/
|
*/
|
||||||
|
@ -50,12 +55,14 @@ class ApiCategoryTree extends ApiBase {
|
||||||
ApiMain $main,
|
ApiMain $main,
|
||||||
$action,
|
$action,
|
||||||
ConfigFactory $configFactory,
|
ConfigFactory $configFactory,
|
||||||
|
IConnectionProvider $dbProvider,
|
||||||
LanguageConverterFactory $languageConverterFactory,
|
LanguageConverterFactory $languageConverterFactory,
|
||||||
WANObjectCache $wanCache
|
WANObjectCache $wanCache
|
||||||
) {
|
) {
|
||||||
parent::__construct( $main, $action );
|
parent::__construct( $main, $action );
|
||||||
$this->configFactory = $configFactory;
|
$this->configFactory = $configFactory;
|
||||||
$this->languageConverterFactory = $languageConverterFactory;
|
$this->languageConverterFactory = $languageConverterFactory;
|
||||||
|
$this->dbProvider = $dbProvider;
|
||||||
$this->wanCache = $wanCache;
|
$this->wanCache = $wanCache;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,7 +129,7 @@ class ApiCategoryTree extends ApiBase {
|
||||||
if ( $condition === 'last-modified' ) {
|
if ( $condition === 'last-modified' ) {
|
||||||
$params = $this->extractRequestParams();
|
$params = $this->extractRequestParams();
|
||||||
$title = CategoryTree::makeTitle( $params['category'] );
|
$title = CategoryTree::makeTitle( $params['category'] );
|
||||||
return wfGetDB( DB_REPLICA )->selectField( 'page', 'page_touched',
|
return $this->dbProvider->getReplicaDatabase()->selectField( 'page', 'page_touched',
|
||||||
[
|
[
|
||||||
'page_namespace' => NS_CATEGORY,
|
'page_namespace' => NS_CATEGORY,
|
||||||
'page_title' => $title->getDBkey(),
|
'page_title' => $title->getDBkey(),
|
||||||
|
|
|
@ -401,7 +401,7 @@ class CategoryTree {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
$dbr = wfGetDB( DB_REPLICA );
|
$dbr = MediaWikiServices::getInstance()->getDBLoadBalancerFactory()->getReplicaDatabase();
|
||||||
|
|
||||||
$inverse = $this->isInverse();
|
$inverse = $this->isInverse();
|
||||||
$mode = $this->getOption( 'mode' );
|
$mode = $this->getOption( 'mode' );
|
||||||
|
@ -522,7 +522,7 @@ class CategoryTree {
|
||||||
public function renderParents( Title $title ) {
|
public function renderParents( Title $title ) {
|
||||||
global $wgCategoryTreeMaxChildren;
|
global $wgCategoryTreeMaxChildren;
|
||||||
|
|
||||||
$dbr = wfGetDB( DB_REPLICA );
|
$dbr = MediaWikiServices::getInstance()->getDBLoadBalancerFactory()->getReplicaDatabase();
|
||||||
|
|
||||||
$res = $dbr->select(
|
$res = $dbr->select(
|
||||||
'categorylinks',
|
'categorylinks',
|
||||||
|
|
Loading…
Reference in a new issue