Fix self link issues about titles in different or mixed variants
authorLiangent <liangent@gmail.com>
Fri, 25 Jan 2013 10:04:54 +0000 (18:04 +0800)
committerLiangent <liangent@gmail.com>
Fri, 25 Jan 2013 10:07:11 +0000 (18:07 +0800)
Change-Id: I64a1b25a45cb8df9fea6fbbfd92cac2e6d53ff98

includes/parser/Parser.php
tests/parser/parserTests.txt

index 0f22755..b19137d 100644 (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;
                                }
index e83a304..26e45ce 100644 (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