From: Matěj Suchánek Date: Thu, 29 Jun 2017 13:06:24 +0000 (+0200) Subject: Linker: Do not localize links to other wikis in comments X-Git-Tag: 1.31.0-rc.0~2788^2 X-Git-Url: http://git.cyclocoop.org/?a=commitdiff_plain;h=922b85bad0ecd4c7e88b29ff5599c14ec731278d;p=lhc%2Fweb%2Fwiklou.git Linker: Do not localize links to other wikis in comments The title, although it refers to a foreign page, is considered local due to Title::isExternal() being false, hence it's namespace prefix is localized. We need to use the canonical namespace name instead. Bug: T169221 Change-Id: I5e5f7d873b9497ca6c8853e7d8170a4f4f07c051 --- diff --git a/includes/Linker.php b/includes/Linker.php index 6942a39935..9ae7cc65c3 100644 --- a/includes/Linker.php +++ b/includes/Linker.php @@ -1331,7 +1331,10 @@ class Linker { $link = Linker::makeExternalLink( WikiMap::getForeignURL( $wikiId, - $title->getPrefixedText(), + $title->getNamespace() === 0 + ? $title->getDBkey() + : MWNamespace::getCanonicalName( $title->getNamespace() ) . ':' + . $title->getDBkey(), $title->getFragment() ), $text, diff --git a/tests/phpunit/includes/LinkerTest.php b/tests/phpunit/includes/LinkerTest.php index 2ca5935225..d684a43750 100644 --- a/tests/phpunit/includes/LinkerTest.php +++ b/tests/phpunit/includes/LinkerTest.php @@ -307,6 +307,11 @@ class LinkerTest extends MediaWikiLangTestCase { 'foo bar [[Special:BlankPage]]', 'enwiki', ], + [ + 'foo bar Image:Example', + 'foo bar [[Image:Example]]', + 'enwiki', + ], ]; // @codingStandardsIgnoreEnd }