MaxSem has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/393937 )
Change subject: [Title] Use a more proper way of detecting whether interwikis
are local
......................................................................
[Title] Use a more proper way of detecting whether interwikis are local
Bug: T181575
Change-Id: Ifcfe609ce01b174120b81b8c0bf82c4ed6077641
---
M includes/Title.php
M tests/phpunit/includes/TitleTest.php
2 files changed, 52 insertions(+), 1 deletion(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/37/393937/1
diff --git a/includes/Title.php b/includes/Title.php
index 829be44..d0d77e3 100644
--- a/includes/Title.php
+++ b/includes/Title.php
@@ -1464,7 +1464,9 @@
public function getFragmentForURL() {
if ( !$this->hasFragment() ) {
return '';
- } elseif ( $this->isExternal() && !$this->getTransWikiID() ) {
+ } elseif ( $this->isExternal()
+ && !self::getInterwikiLookup()->fetch(
$this->mInterwiki )->isLocal()
+ ) {
return '#' . Sanitizer::escapeIdForExternalInterwiki(
$this->getFragment() );
}
return '#' . Sanitizer::escapeIdForLink( $this->getFragment() );
diff --git a/tests/phpunit/includes/TitleTest.php
b/tests/phpunit/includes/TitleTest.php
index 5a92b99..75adfab 100644
--- a/tests/phpunit/includes/TitleTest.php
+++ b/tests/phpunit/includes/TitleTest.php
@@ -911,4 +911,53 @@
public function testGetPrefixedDBKey( Title $title, $expected ) {
$this->assertEquals( $expected, $title->getPrefixedDBkey() );
}
+
+ /**
+ * @dataProvider provideGetFragmentForURL
+ *
+ * @param string $titleStr
+ * @param string $expected
+ */
+ public function testGetFragmentForURL( $titleStr, $expected ) {
+ $this->setMwGlobals( [
+ 'wgFragmentMode' => [ 'html5' ],
+ 'wgExternalInterwikiFragmentMode' => 'legacy',
+ ] );
+ $dbw = wfGetDB( DB_MASTER );
+ $dbw->insert( 'interwiki',
+ [
+ [
+ 'iw_prefix' => 'de',
+ 'iw_url' =>
'http://de.wikipedia.org/wiki/',
+ 'iw_api' =>
'http://de.wikipedia.org/w/api.php',
+ 'iw_wikiid' => 'dewiki',
+ 'iw_local' => 1,
+ 'iw_trans' => 0
+ ],
+ [
+ 'iw_prefix' => 'zz',
+ 'iw_url' => 'http://zzwiki.org/wiki/',
+ 'iw_api' => 'http://zzwiki.org/w/api.php',
+ 'iw_wikiid' => 'zzwiki',
+ 'iw_local' => 0,
+ 'iw_trans' => 0
+ ],
+ ],
+ __METHOD__,
+ [ 'IGNORE' ]
+ );
+
+ $title = Title::newFromText( $titleStr );
+ self::assertEquals( $expected, $title->getFragmentForURL() );
+
+ $dbw->delete( 'interwiki', '*', __METHOD__ );
+ }
+
+ public function provideGetFragmentForURL() {
+ return [
+ [ 'Foo#ümlåût', '#ümlåût' ],
+ [ 'de:Foo#Bå®', '#Bå®' ],
+ [ 'zz:Foo#тест', '#.D1.82.D0.B5.D1.81.D1.82' ],
+ ];
+ }
}
--
To view, visit https://gerrit.wikimedia.org/r/393937
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ifcfe609ce01b174120b81b8c0bf82c4ed6077641
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: MaxSem <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits