mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Interwiki
synced 2024-11-23 14:06:55 +00:00
Replace wfGetDB() with ICP getReplicaDatabase() etc.
Ahead of any decision to merge this extension into core, let's actually fix this now. Bug: T357646 Change-Id: I5128ce524c1a6a04bbe8b7607747eab84d892059
This commit is contained in:
parent
a6a4562141
commit
b22041413c
|
@ -59,18 +59,22 @@ class Hooks implements UserGetAllRightsHook {
|
|||
|
||||
public static function onInterwikiLoadPrefix( $prefix, &$iwData ) {
|
||||
global $wgInterwikiCentralDB, $wgInterwikiCentralInterlanguageDB;
|
||||
$isInterlanguageLink = MediaWikiServices::getInstance()->getLanguageNameUtils()->getLanguageName( $prefix );
|
||||
|
||||
$services = MediaWikiServices::getInstance();
|
||||
$connectionProvider = $services->getConnectionProvider();
|
||||
$isInterlanguageLink = $services->getLanguageNameUtils()->getLanguageName( $prefix );
|
||||
if ( !$isInterlanguageLink && !self::$shouldSkipIWCheck ) {
|
||||
// Check if prefix exists locally and skip
|
||||
$lookup = MediaWikiServices::getInstance()->getInterwikiLookup();
|
||||
$lookup = $services->getInterwikiLookup();
|
||||
foreach ( $lookup->getAllPrefixes( null ) as $id => $localPrefixInfo ) {
|
||||
if ( $prefix === $localPrefixInfo['iw_prefix'] ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// @phan-suppress-next-line PhanTypeMismatchArgument
|
||||
$dbr = wfGetDB( DB_REPLICA, [], $wgInterwikiCentralDB );
|
||||
$res = $dbr->selectRow(
|
||||
|
||||
$dbrCentralDB = $connectionProvider->getReplicaDatabase( $wgInterwikiCentralDB ?? false );
|
||||
|
||||
$res = $dbrCentralDB->selectRow(
|
||||
'interwiki',
|
||||
'*',
|
||||
[ 'iw_prefix' => $prefix ],
|
||||
|
@ -85,9 +89,9 @@ class Hooks implements UserGetAllRightsHook {
|
|||
return false;
|
||||
} elseif ( $isInterlanguageLink && !self::$shouldSkipILCheck ) {
|
||||
// Global interlanguage link? Whoo!
|
||||
// @phan-suppress-next-line PhanTypeMismatchArgument
|
||||
$dbr = wfGetDB( DB_REPLICA, [], $wgInterwikiCentralInterlanguageDB );
|
||||
$res = $dbr->selectRow(
|
||||
$dbrCentralLangDB = $connectionProvider->getReplicaDatabase( $wgInterwikiCentralInterlanguageDB ?? false );
|
||||
|
||||
$res = $dbrCentralLangDB->selectRow(
|
||||
'interwiki',
|
||||
'*',
|
||||
[ 'iw_prefix' => $prefix ],
|
||||
|
|
|
@ -188,7 +188,7 @@ class SpecialInterwiki extends SpecialPage {
|
|||
];
|
||||
|
||||
if ( $action === 'edit' ) {
|
||||
$dbr = wfGetDB( DB_REPLICA );
|
||||
$dbr = MediaWikiServices::getInstance()->getConnectionProvider()->getReplicaDatabase();
|
||||
$row = $dbr->selectRow( 'interwiki', '*', [ 'iw_prefix' => $prefix ], __METHOD__ );
|
||||
|
||||
$formDescriptor['prefix']['disabled'] = true;
|
||||
|
@ -233,6 +233,8 @@ class SpecialInterwiki extends SpecialPage {
|
|||
}
|
||||
|
||||
public function onSubmit( array $data ) {
|
||||
$services = MediaWikiServices::getInstance();
|
||||
|
||||
$status = Status::newGood();
|
||||
$request = $this->getRequest();
|
||||
$config = $this->getConfig();
|
||||
|
@ -250,7 +252,7 @@ class SpecialInterwiki extends SpecialPage {
|
|||
// Disallow adding local interlanguage definitions if using global
|
||||
$interwikiCentralInterlanguageDB = $config->get( 'InterwikiCentralInterlanguageDB' );
|
||||
if (
|
||||
$do === 'add' && MediaWikiServices::getInstance()->getLanguageNameUtils()->getLanguageName( $prefix )
|
||||
$do === 'add' && $services->getLanguageNameUtils()->getLanguageName( $prefix )
|
||||
&& $interwikiCentralInterlanguageDB !== WikiMap::getCurrentWikiId()
|
||||
&& $interwikiCentralInterlanguageDB !== null
|
||||
) {
|
||||
|
@ -259,8 +261,8 @@ class SpecialInterwiki extends SpecialPage {
|
|||
}
|
||||
$reason = $data['reason'];
|
||||
$selfTitle = $this->getPageTitle();
|
||||
$lookup = MediaWikiServices::getInstance()->getInterwikiLookup();
|
||||
$dbw = wfGetDB( DB_PRIMARY );
|
||||
$lookup = $services->getInterwikiLookup();
|
||||
$dbw = $services->getConnectionProvider()->getPrimaryDatabase();
|
||||
switch ( $do ) {
|
||||
case 'delete':
|
||||
$dbw->delete( 'interwiki', [ 'iw_prefix' => $prefix ], __METHOD__ );
|
||||
|
@ -282,7 +284,7 @@ class SpecialInterwiki extends SpecialPage {
|
|||
break;
|
||||
/** @noinspection PhpMissingBreakStatementInspection */
|
||||
case 'add':
|
||||
$contLang = MediaWikiServices::getInstance()->getContentLanguage();
|
||||
$contLang = $services->getContentLanguage();
|
||||
$prefix = $contLang->lc( $prefix );
|
||||
// Fall through
|
||||
case 'edit':
|
||||
|
@ -344,16 +346,24 @@ class SpecialInterwiki extends SpecialPage {
|
|||
$canModify = $this->canModify();
|
||||
|
||||
// Build lists
|
||||
$lookup = MediaWikiServices::getInstance()->getInterwikiLookup();
|
||||
$services = MediaWikiServices::getInstance();
|
||||
|
||||
$lookup = $services->getInterwikiLookup();
|
||||
$iwPrefixes = $lookup->getAllPrefixes( null );
|
||||
$iwGlobalPrefixes = [];
|
||||
$iwGlobalLanguagePrefixes = [];
|
||||
|
||||
$config = $this->getConfig();
|
||||
$interwikiCentralDB = $config->get( 'InterwikiCentralDB' );
|
||||
$languageNameUtils = MediaWikiServices::getInstance()->getLanguageNameUtils();
|
||||
|
||||
$languageNameUtils = $services->getLanguageNameUtils();
|
||||
|
||||
$connectionProvider = $services->getConnectionProvider();
|
||||
|
||||
if ( $interwikiCentralDB !== null && $interwikiCentralDB !== WikiMap::getCurrentWikiId() ) {
|
||||
// Fetch list from global table
|
||||
$dbrCentralDB = wfGetDB( DB_REPLICA, [], $interwikiCentralDB );
|
||||
$dbrCentralDB = $connectionProvider->getReplicaDatabase( $interwikiCentralDB );
|
||||
|
||||
$res = $dbrCentralDB->select( 'interwiki', '*', [], __METHOD__ );
|
||||
$retval = [];
|
||||
foreach ( $res as $row ) {
|
||||
|
@ -373,7 +383,8 @@ class SpecialInterwiki extends SpecialPage {
|
|||
$usingGlobalLanguages = $usingGlobalInterlangLinks && !$isGlobalInterlanguageDB;
|
||||
if ( $usingGlobalLanguages ) {
|
||||
// Fetch list from global table
|
||||
$dbrCentralLangDB = wfGetDB( DB_REPLICA, [], $interwikiCentralInterlanguageDB );
|
||||
$dbrCentralLangDB = $connectionProvider->getReplicaDatabase( $interwikiCentralInterlanguageDB );
|
||||
|
||||
$res = $dbrCentralLangDB->select( 'interwiki', '*', [], __METHOD__ );
|
||||
$retval2 = [];
|
||||
foreach ( $res as $row ) {
|
||||
|
|
Loading…
Reference in a new issue