From d80ebf9c91edfaa1febc369c1332059ed4312519 Mon Sep 17 00:00:00 2001 From: Liangent Date: Mon, 21 May 2012 22:59:10 +0800 Subject: [PATCH] In LinkHolderArray::doVariants(), redlinks need to be checked as well. 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 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/includes/parser/LinkHolderArray.php b/includes/parser/LinkHolderArray.php index def1aee4b0..02077f9a8c 100644 --- a/includes/parser/LinkHolderArray.php +++ b/includes/parser/LinkHolderArray.php @@ -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; -- 2.20.1