In LinkHolderArray::doVariants(), redlinks need to be checked as well.
authorLiangent <liangent@gmail.com>
Mon, 21 May 2012 14:59:10 +0000 (22:59 +0800)
committerLiangent <liangent@gmail.com>
Mon, 2 Jul 2012 11:51:55 +0000 (19:51 +0800)
Currently a simple Title::exists() or Title::getArticleId() call on a
non-existent title can cause the title marked as redlinks in LinkCache,
even if a title in another variant exists. A visible appearance is that
the function refuses to try other variants of a link if the link has
already been checked by {{#ifexist:}}, which internally calls
$lang->findVariantLink() then $title->exists() is invoked.

$titlesToBeConverted is also tweaked to avoid the trailing "\0".

Change-Id: I741e2938eb364ed29f10f058da260848a6774f9f

includes/parser/LinkHolderArray.php

index def1aee..02077f9 100644 (file)
@@ -453,7 +453,7 @@ class LinkHolderArray {
                        foreach ( $entries as $index => $entry ) {
                                $pdbk = $entry['pdbk'];
                                // we only deal with new links (in its first query)
-                               if ( !isset( $colours[$pdbk] ) ) {
+                               if ( !isset( $colours[$pdbk] ) || $colours[$pdbk] === 'new' ) {
                                        $title = $entry['title'];
                                        $titleText = $title->getText();
                                        $titlesAttrs[] = array(
@@ -469,7 +469,7 @@ class LinkHolderArray {
                }
 
                // Now do the conversion and explode string to text of titles
-               $titlesAllVariants = $wgContLang->autoConvertToAllVariants( $titlesToBeConverted );
+               $titlesAllVariants = $wgContLang->autoConvertToAllVariants( rtrim( $titlesToBeConverted, "\0" ) );
                $allVariantsName = array_keys( $titlesAllVariants );
                foreach ( $titlesAllVariants as &$titlesVariant ) {
                        $titlesVariant = explode( "\0", $titlesVariant );
@@ -537,7 +537,7 @@ class LinkHolderArray {
                                        $entry =& $this->internals[$ns][$index];
                                        $pdbk = $entry['pdbk'];
 
-                                       if(!isset($colours[$pdbk])){
+                                       if ( !isset( $colours[$pdbk] ) || $colours[$pdbk] === 'new' ) {
                                                // found link in some of the variants, replace the link holder data
                                                $entry['title'] = $variantTitle;
                                                $entry['pdbk'] = $varPdbk;