Georggi199 has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/331455 )
Change subject: Removed deprecated usages of Interwiki methods in core ...................................................................... Removed deprecated usages of Interwiki methods in core Change-Id: Ibd25968660466c44189ccb01df1d8bec6e1b207c --- M includes/api/ApiQuerySiteinfo.php M includes/import/ImportStreamSource.php M includes/title/MediaWikiTitleCodec.php M maintenance/namespaceDupes.php M tests/phpunit/includes/interwiki/InterwikiTest.php 5 files changed, 30 insertions(+), 25 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/55/331455/1 diff --git a/includes/api/ApiQuerySiteinfo.php b/includes/api/ApiQuerySiteinfo.php index 6fc6aa3..446313c 100644 --- a/includes/api/ApiQuerySiteinfo.php +++ b/includes/api/ApiQuerySiteinfo.php @@ -388,7 +388,7 @@ $langCode = isset( $params['inlanguagecode'] ) ? $params['inlanguagecode'] : ''; $langNames = Language::fetchLanguageNames( $langCode ); - $getPrefixes = Interwiki::getAllPrefixes( $local ); + $getPrefixes = MediaWiki\MediaWikiServices::getInstance()->getInterwikiLookup()->getAllPrefixes( $local ); $extraLangPrefixes = $this->getConfig()->get( 'ExtraInterlanguageLinkPrefixes' ); $localInterwikis = $this->getConfig()->get( 'LocalInterwikis' ); $data = []; diff --git a/includes/import/ImportStreamSource.php b/includes/import/ImportStreamSource.php index 0c12ebb..96b3bc2 100644 --- a/includes/import/ImportStreamSource.php +++ b/includes/import/ImportStreamSource.php @@ -148,7 +148,8 @@ # Look up the first interwiki prefix, and let the foreign site handle # subsequent interwiki prefixes $firstIwPrefix = strtok( $interwiki, ':' ); - $firstIw = Interwiki::fetch( $firstIwPrefix ); + $interwikiLookup = MediaWiki\MediaWikiServices::getInstance()->getInterwikiLookup(); + $firstIw = $interwikiLookup->fetch( $firstIwPrefix ); if ( !$firstIw ) { return Status::newFatal( 'importbadinterwiki' ); } diff --git a/includes/title/MediaWikiTitleCodec.php b/includes/title/MediaWikiTitleCodec.php index a937e75..f43886f 100644 --- a/includes/title/MediaWikiTitleCodec.php +++ b/includes/title/MediaWikiTitleCodec.php @@ -309,6 +309,7 @@ if ( preg_match( $prefixRegexp, $dbkey, $m ) ) { $p = $m[1]; $ns = $this->language->getNsIndex( $p ); + $interwikiLookup = MediaWiki\MediaWikiServices::getInstance()->getInterwikiLookup(); if ( $ns !== false ) { # Ordinary namespace $dbkey = $m[2]; @@ -318,13 +319,13 @@ if ( $this->language->getNsIndex( $x[1] ) ) { # Disallow Talk:File:x type titles... throw new MalformedTitleException( 'title-invalid-talk-namespace', $text ); - } elseif ( Interwiki::isValidInterwiki( $x[1] ) ) { + } elseif ( $interwikiLookup->isValidInterwiki( $x[1] ) ) { // TODO: get rid of global state! # Disallow Talk:Interwiki:x type titles... throw new MalformedTitleException( 'title-invalid-talk-namespace', $text ); } } - } elseif ( Interwiki::isValidInterwiki( $p ) ) { + } elseif ( $interwikiLookup->isValidInterwiki( $p ) ) { # Interwiki link $dbkey = $m[2]; $parts['interwiki'] = $this->language->lc( $p ); diff --git a/maintenance/namespaceDupes.php b/maintenance/namespaceDupes.php index b705500..0ebd71e 100644 --- a/maintenance/namespaceDupes.php +++ b/maintenance/namespaceDupes.php @@ -224,7 +224,7 @@ * @return array */ private function getInterwikiList() { - $result = Interwiki::getAllPrefixes(); + $result = MediaWiki\MediaWikiServices::getInstance()->getInterwikiLookup()->getAllPrefixes(); $prefixes = []; foreach ( $result as $row ) { $prefixes[] = $row['iw_prefix']; diff --git a/tests/phpunit/includes/interwiki/InterwikiTest.php b/tests/phpunit/includes/interwiki/InterwikiTest.php index 137dfb7..b1ad77a 100644 --- a/tests/phpunit/includes/interwiki/InterwikiTest.php +++ b/tests/phpunit/includes/interwiki/InterwikiTest.php @@ -82,31 +82,32 @@ $this->setWgInterwikiCache( false ); + $interwikiLookup = MediaWikiServices::getInstance()->getInterwikiLookup(); $this->assertEquals( [ $dewiki, $zzwiki ], - Interwiki::getAllPrefixes(), + $interwikiLookup->getAllPrefixes(), 'getAllPrefixes()' ); $this->assertEquals( [ $dewiki ], - Interwiki::getAllPrefixes( true ), + $interwikiLookup->getAllPrefixes( true ), 'getAllPrefixes()' ); $this->assertEquals( [ $zzwiki ], - Interwiki::getAllPrefixes( false ), + $interwikiLookup->getAllPrefixes( false ), 'getAllPrefixes()' ); - $this->assertTrue( Interwiki::isValidInterwiki( 'de' ), 'known prefix is valid' ); - $this->assertFalse( Interwiki::isValidInterwiki( 'xyz' ), 'unknown prefix is valid' ); + $this->assertTrue( $interwikiLookup->isValidInterwiki( 'de' ), 'known prefix is valid' ); + $this->assertFalse( $interwikiLookup->isValidInterwiki( 'xyz' ), 'unknown prefix is valid' ); - $this->assertNull( Interwiki::fetch( null ), 'no prefix' ); - $this->assertFalse( Interwiki::fetch( 'xyz' ), 'unknown prefix' ); + $this->assertNull( $interwikiLookup->fetch( null ), 'no prefix' ); + $this->assertFalse( $interwikiLookup->fetch( 'xyz' ), 'unknown prefix' ); - $interwiki = Interwiki::fetch( 'de' ); + $interwiki = $interwikiLookup->fetch( 'de' ); $this->assertInstanceOf( 'Interwiki', $interwiki ); - $this->assertSame( $interwiki, Interwiki::fetch( 'de' ), 'in-process caching' ); + $this->assertSame( $interwiki, $interwikiLookup->fetch( 'de' ), 'in-process caching' ); $this->assertSame( 'http://de.wikipedia.org/wiki/', $interwiki->getURL(), 'getURL' ); $this->assertSame( 'http://de.wikipedia.org/w/api.php', $interwiki->getAPI(), 'getAPI' ); @@ -115,7 +116,7 @@ $this->assertSame( false, $interwiki->isTranscludable(), 'isTranscludable' ); Interwiki::invalidateCache( 'de' ); - $this->assertNotSame( $interwiki, Interwiki::fetch( 'de' ), 'invalidate cache' ); + $this->assertNotSame( $interwiki, $interwikiLookup->fetch( 'de' ), 'invalidate cache' ); } /** @@ -190,22 +191,23 @@ $this->setWgInterwikiCache( $cdbFile ); + $interwikiLookup = MediaWikiServices::getInstance()->getInterwikiLookup(); $this->assertEquals( [ $dewiki, $zzwiki ], - Interwiki::getAllPrefixes(), + $interwikiLookup->getAllPrefixes(), 'getAllPrefixes()' ); - $this->assertTrue( Interwiki::isValidInterwiki( 'de' ), 'known prefix is valid' ); - $this->assertTrue( Interwiki::isValidInterwiki( 'zz' ), 'known prefix is valid' ); + $this->assertTrue( $interwikiLookup->isValidInterwiki( 'de' ), 'known prefix is valid' ); + $this->assertTrue( $interwikiLookup->isValidInterwiki( 'zz' ), 'known prefix is valid' ); - $interwiki = Interwiki::fetch( 'de' ); + $interwiki = $interwikiLookup->fetch( 'de' ); $this->assertInstanceOf( 'Interwiki', $interwiki ); $this->assertSame( 'http://de.wikipedia.org/wiki/', $interwiki->getURL(), 'getURL' ); $this->assertSame( true, $interwiki->isLocal(), 'isLocal' ); - $interwiki = Interwiki::fetch( 'zz' ); + $interwiki = $interwikiLookup->fetch( 'zz' ); $this->assertInstanceOf( 'Interwiki', $interwiki ); $this->assertSame( 'http://zzwiki.org/wiki/', $interwiki->getURL(), 'getURL' ); @@ -236,22 +238,23 @@ $this->setWgInterwikiCache( $cdbData ); + $interwikiLookup = MediaWikiServices::getInstance()->getInterwikiLookup(); $this->assertEquals( [ $dewiki, $zzwiki ], - Interwiki::getAllPrefixes(), + $interwikiLookup->getAllPrefixes(), 'getAllPrefixes()' ); - $this->assertTrue( Interwiki::isValidInterwiki( 'de' ), 'known prefix is valid' ); - $this->assertTrue( Interwiki::isValidInterwiki( 'zz' ), 'known prefix is valid' ); + $this->assertTrue( $interwikiLookup->isValidInterwiki( 'de' ), 'known prefix is valid' ); + $this->assertTrue( $interwikiLookup->isValidInterwiki( 'zz' ), 'known prefix is valid' ); - $interwiki = Interwiki::fetch( 'de' ); + $interwiki = $interwikiLookup->fetch( 'de' ); $this->assertInstanceOf( 'Interwiki', $interwiki ); $this->assertSame( 'http://de.wikipedia.org/wiki/', $interwiki->getURL(), 'getURL' ); $this->assertSame( true, $interwiki->isLocal(), 'isLocal' ); - $interwiki = Interwiki::fetch( 'zz' ); + $interwiki = $interwikiLookup->fetch( 'zz' ); $this->assertInstanceOf( 'Interwiki', $interwiki ); $this->assertSame( 'http://zzwiki.org/wiki/', $interwiki->getURL(), 'getURL' ); -- To view, visit https://gerrit.wikimedia.org/r/331455 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ibd25968660466c44189ccb01df1d8bec6e1b207c Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Georggi199 <bmp2...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits