From bca8b8ad7d2f4da53169c4d242b912829d8a3430 Mon Sep 17 00:00:00 2001 From: Liangent Date: Fri, 25 Jan 2013 18:04:54 +0800 Subject: [PATCH] Fix self link issues about titles in different or mixed variants Change-Id: I64a1b25a45cb8df9fea6fbbfd92cac2e6d53ff98 --- includes/parser/Parser.php | 12 +++++------- tests/parser/parserTests.txt | 16 ++++++++++++++++ 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index 0f22755e09..b19137d71c 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -1814,12 +1814,6 @@ class Parser { $prefix = ''; } - if ( $this->getConverterLanguage()->hasVariants() ) { - $selflink = $this->getConverterLanguage()->autoConvertToAllVariants( - $this->mTitle->getPrefixedText() ); - } else { - $selflink = array( $this->mTitle->getPrefixedText() ); - } $useSubpages = $this->areSubpagesAllowed(); wfProfileOut( __METHOD__.'-setup' ); @@ -2055,7 +2049,11 @@ class Parser { # Self-link checking if ( $nt->getFragment() === '' && $ns != NS_SPECIAL ) { - if ( in_array( $nt->getPrefixedText(), $selflink, true ) ) { + if ( $nt->equals( $this->mTitle ) || ( !$nt->isKnown() && in_array( + $this->mTitle->getPrefixedText(), + $this->getConverterLanguage()->autoConvertToAllVariants( $nt->getPrefixedText() ), + true + ) ) ) { $s .= $prefix . Linker::makeSelfLinkObj( $nt, $text, '', $trail ); continue; } diff --git a/tests/parser/parserTests.txt b/tests/parser/parserTests.txt index e83a3041bf..26e45cede6 100644 --- a/tests/parser/parserTests.txt +++ b/tests/parser/parserTests.txt @@ -10851,6 +10851,22 @@ Both [[Dunav]] and [[Дунав]] are names for this river.

!!end +!! article +Дуна +!! text +content +!! endarticle + +!! test +Link to another existing title shouldn't be parsed as self-link even if it's a variant of this title +!! options +title=[[Duna]] language=sr +!! input +[[Дуна]] is not a self-link while [[Duna]] and [[Dуна]] are still self-links. +!! result +

Дуна is not a self-link while Duna and Dуна are still self-links. +

+!! end !! test Link to pages in language variants -- 2.20.1