Fix self link issues about titles in different or mixed variants

Change-Id: I64a1b25a45cb8df9fea6fbbfd92cac2e6d53ff98
This commit is contained in:
Liangent 2013-01-25 18:04:54 +08:00
parent 6d2ed516be
commit bca8b8ad7d
2 changed files with 21 additions and 7 deletions

View file

@ -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;
}

View file

@ -10851,6 +10851,22 @@ Both [[Dunav]] and [[Дунав]] are names for this river.
</p>
!!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
<p><a href="/wiki/%D0%94%D1%83%D0%BD%D0%B0" title="Дуна">Дуна</a> is not a self-link while <strong class="selflink">Duna</strong> and <strong class="selflink">Dуна</strong> are still self-links.
</p>
!! end
!! test
Link to pages in language variants