From: Liangent Date: Mon, 21 May 2012 15:33:32 +0000 (+0800) Subject: (bug 33210) Don't convert blue categorylinks to another variant. X-Git-Tag: 1.31.0-rc.0~21155 X-Git-Url: http://git.cyclocoop.org/%24image?a=commitdiff_plain;h=d266580c5bd93f03c57bc30b259c72a0603bbd5e;p=lhc%2Fweb%2Fwiklou.git (bug 33210) Don't convert blue categorylinks to another variant. By the way the check $oldkey != $vardbk is unnecessary because there's already $variant != $category check. Change-Id: I963be065723059073c9cb83c6ef636af8d023faf --- diff --git a/includes/parser/LinkHolderArray.php b/includes/parser/LinkHolderArray.php index e1fdbc342d..083bd29893 100644 --- a/includes/parser/LinkHolderArray.php +++ b/includes/parser/LinkHolderArray.php @@ -497,14 +497,18 @@ class LinkHolderArray { // process categories, check if a category exists in some variant $categoryMap = array(); // maps $category_variant => $category (dbkeys) $varCategories = array(); // category replacements oldDBkey => newDBkey - foreach( $output->getCategoryLinks() as $category ){ + foreach ( $output->getCategoryLinks() as $category ) { + $categoryTitle = Title::makeTitleSafe( NS_CATEGORY, $category ); + $linkBatch->addObj( $categoryTitle ); $variants = $wgContLang->autoConvertToAllVariants( $category ); - foreach($variants as $variant){ - if($variant != $category){ - $variantTitle = Title::newFromDBkey( Title::makeName(NS_CATEGORY,$variant) ); - if(is_null($variantTitle)) continue; + foreach ( $variants as $variant ) { + if ( $variant !== $category ) { + $variantTitle = Title::makeTitleSafe( NS_CATEGORY, $variant ); + if ( is_null( $variantTitle ) ) { + continue; + } $linkBatch->addObj( $variantTitle ); - $categoryMap[$variant] = $category; + $categoryMap[$variant] = array( $category, $categoryTitle ); } } } @@ -556,10 +560,11 @@ class LinkHolderArray { } // check if the object is a variant of a category - if(isset($categoryMap[$vardbk])){ - $oldkey = $categoryMap[$vardbk]; - if($oldkey != $vardbk) - $varCategories[$oldkey]=$vardbk; + if ( isset( $categoryMap[$vardbk] ) ) { + list( $oldkey, $oldtitle ) = $categoryMap[$vardbk]; + if ( !isset( $varCategories[$oldkey] ) && !$oldtitle->exists() ) { + $varCategories[$oldkey] = $vardbk; + } } } wfRunHooks( 'GetLinkColours', array( $linkcolour_ids, &$colours ) ); diff --git a/tests/parser/parserTests.txt b/tests/parser/parserTests.txt index e8aca7bb57..8aac86ddf7 100644 --- a/tests/parser/parserTests.txt +++ b/tests/parser/parserTests.txt @@ -10895,6 +10895,29 @@ language=sr cat !! end +!! article +Category:分类 +!! text +blah +!! endarticle + +!! article +Category:分類 +!! text +blah +!! endarticle + +!! test +Don't convert blue categorylinks to another variant (bug 33210) +!! options +language=zh cat +!! input +[[A]][[Category:分类]] +!! result +分类 +!! end + + !! test Stripping -{}- tags (language variants) !! options