From: Tim Starling Date: Wed, 26 Sep 2012 07:42:17 +0000 (+1000) Subject: Don't display multiple language links to the same language X-Git-Tag: 1.31.0-rc.0~22135^2 X-Git-Url: http://git.cyclocoop.org/%22%2C%20generer_url_ecrire%28?a=commitdiff_plain;h=d5a0ddcca4190d3148f72de7fce56f08b2c42823;p=lhc%2Fweb%2Fwiklou.git Don't display multiple language links to the same language (bug 24502) Resolve the various issues with this accidental feature by removing it. I think it could be done properly, along the lines of my comment #5, but I don't think just changing the DB schema to make langlinks non-unique is a good direction to take. A comment on I4e1e08a3 from Daniel Kinzler indicates that duplicate language links won't be possible with Wikidata anyway, so there's not much value in I4e1e08a3 for WMF wikis. Change-Id: Iba5f3f29e20f5119d4414b1e87ce5eee674701a8 --- diff --git a/RELEASE-NOTES-1.20 b/RELEASE-NOTES-1.20 index 3ba5a13897..848e07a66b 100644 --- a/RELEASE-NOTES-1.20 +++ b/RELEASE-NOTES-1.20 @@ -244,6 +244,7 @@ upgrade PHP if you have not done so prior to upgrading MediaWiki. * (bug 39635) PostgreSQL LOCK IN SHARE MODE option is a syntax error. * (bug 36329) Accesskey tooltips for Firefox 14 on Mac should use "ctrl-option-" prefix. * (bug 32552) Drop unused database field cat_hidden from table category. +* (bug 24502) Do not allow multiple language links to the same language. * (bug 40214) Category pages no longer use deprecated "width" HTML attribute. * (bug 39941) Add missing stylesheets to the installer pages * In HTML5 mode, allow new input element types values (such as color, range..) diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index 59d379a06e..abc017bc9d 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -200,6 +200,13 @@ class Parser { */ var $mUniqPrefix; + /** + * @var Array with the language name of each language link (i.e. the + * interwiki prefix) in the key, value arbitrary. Used to avoid sending + * duplicate language links to the ParserOutput. + */ + var $mLangLinkLanguages; + /** * Constructor * @@ -282,6 +289,7 @@ class Parser { $this->mRevisionId = $this->mRevisionUser = null; $this->mVarCache = array(); $this->mUser = null; + $this->mLangLinkLanguages = array(); /** * Prefix for temporary replacement strings for the multipass parser. @@ -1953,7 +1961,11 @@ class Parser { # Interwikis wfProfileIn( __METHOD__."-interwiki" ); if ( $iw && $this->mOptions->getInterwikiMagic() && $nottalk && Language::fetchLanguageName( $iw, null, 'mw' ) ) { - $this->mOutput->addLanguageLink( $nt->getFullText() ); + # Bug 24502: filter duplicates + if ( !isset( $this->mLangLinkLanguages[$iw] ) ) { + $this->mLangLinkLanguages[$iw] = true; + $this->mOutput->addLanguageLink( $nt->getFullText() ); + } $s = rtrim( $s . $prefix ); $s .= trim( $trail, "\n" ) == '' ? '': $prefix . $trail; wfProfileOut( __METHOD__."-interwiki" ); diff --git a/tests/parser/parserTests.txt b/tests/parser/parserTests.txt index 0c767c7ee1..7c2f2913fb 100644 --- a/tests/parser/parserTests.txt +++ b/tests/parser/parserTests.txt @@ -5553,6 +5553,19 @@ ill es:Alimento fr:Nourriture zh:食品 !! end +!! test +Duplicate interlanguage links (bug 24502) +!! options +ill +!! input +[[es:1]] +[[es:2]] +[[fr:1]] +[[fr:2]] +!! result +es:1 fr:1 +!! end + ### ### Sections ###