mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/PageImages
synced 2024-11-24 08:23:28 +00:00
Replace deprecated global function wfGetDB()
Bug: T330641 Change-Id: If0427da7a6d2de9d1ec00bf1ff7e5b8a495617e9
This commit is contained in:
parent
029af825a9
commit
318407932c
|
@ -37,6 +37,7 @@
|
|||
"main": {
|
||||
"class": "PageImages\\PageImages",
|
||||
"services": [
|
||||
"DBLoadBalancerFactory",
|
||||
"RepoGroup",
|
||||
"UserOptionsLookup"
|
||||
]
|
||||
|
|
|
@ -18,6 +18,7 @@ use MediaWiki\User\UserOptionsLookup;
|
|||
use OutputPage;
|
||||
use RepoGroup;
|
||||
use Skin;
|
||||
use Wikimedia\Rdbms\IConnectionProvider;
|
||||
|
||||
/**
|
||||
* @license WTFPL
|
||||
|
@ -59,6 +60,9 @@ class PageImages implements
|
|||
*/
|
||||
public const PROP_NAME_FREE = 'page_image_free';
|
||||
|
||||
/** @var IConnectionProvider */
|
||||
private $dbProvider;
|
||||
|
||||
/** @var RepoGroup */
|
||||
private $repoGroup;
|
||||
|
||||
|
@ -74,19 +78,23 @@ class PageImages implements
|
|||
private static function factory() {
|
||||
$services = MediaWikiServices::getInstance();
|
||||
return new self(
|
||||
$services->getDBLoadBalancerFactory(),
|
||||
$services->getRepoGroup(),
|
||||
$services->getUserOptionsLookup()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param IConnectionProvider $dbProvider
|
||||
* @param RepoGroup $repoGroup
|
||||
* @param UserOptionsLookup $userOptionsLookup
|
||||
*/
|
||||
public function __construct(
|
||||
IConnectionProvider $dbProvider,
|
||||
RepoGroup $repoGroup,
|
||||
UserOptionsLookup $userOptionsLookup
|
||||
) {
|
||||
$this->dbProvider = $dbProvider;
|
||||
$this->repoGroup = $repoGroup;
|
||||
$this->userOptionsLookup = $userOptionsLookup;
|
||||
}
|
||||
|
@ -170,7 +178,7 @@ class PageImages implements
|
|||
return null;
|
||||
}
|
||||
|
||||
$dbr = wfGetDB( DB_REPLICA );
|
||||
$dbr = $this->dbProvider->getReplicaDatabase();
|
||||
$fileName = $dbr->selectField( 'page_props',
|
||||
'pp_value',
|
||||
[
|
||||
|
|
|
@ -58,7 +58,8 @@ class InitImageData extends Maintenance {
|
|||
'LEFT JOIN', 'page_id = il_from',
|
||||
] ];
|
||||
|
||||
$dbr = wfGetDB( DB_REPLICA );
|
||||
$dbr = $this->getServiceContainer()->getDBLoadBalancerFactory()
|
||||
->getReplicaDatabase();
|
||||
if ( $this->hasOption( 'namespaces' ) ) {
|
||||
$ns = explode( ',', $this->getOption( 'namespaces' ) );
|
||||
$conds['page_namespace'] = $ns;
|
||||
|
|
|
@ -24,6 +24,7 @@ class PageImagesTest extends MediaWikiIntegrationTestCase {
|
|||
private function newPageImages() {
|
||||
$services = $this->getServiceContainer();
|
||||
return new PageImages(
|
||||
$services->getDBLoadBalancerFactory(),
|
||||
$services->getRepoGroup(),
|
||||
$services->getUserOptionsLookup()
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue