From 922b85bad0ecd4c7e88b29ff5599c14ec731278d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Mat=C4=9Bj=20Such=C3=A1nek?= Date: Thu, 29 Jun 2017 15:06:24 +0200 Subject: [PATCH] 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 --- includes/Linker.php | 5 ++++- tests/phpunit/includes/LinkerTest.php | 5 +++++ 2 files changed, 9 insertions(+), 1 deletion(-) 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 } -- 2.20.1