r113000 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r112999‎ | r113000 | r113001 >
Date:05:41, 5 March 2012
Author:santhosh
Status:resolved (Comments)
Tags:
Comment:
Remove invalid language codes from the priority languages.
Modified paths:
  • /trunk/extensions/Translate/tag/SpecialPageTranslation.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Translate/tag/SpecialPageTranslation.php
@@ -700,6 +700,13 @@
701701 // Normalize
702702 $npLangs = array_map( 'trim', explode( ',', $npLangs ) );
703703 $npLangs = array_unique( $npLangs );
 704+ // Remove invalid language codes.
 705+ $languages = Language::fetchLanguageNames( null, 'mw' );
 706+ foreach ( $npLangs as $index => $language ) {
 707+ if( !array_key_exists( $language, $languages ) ) {
 708+ unset( $npLangs[$index] );
 709+ }
 710+ }
704711 $npLangs = implode( ',', $npLangs );
705712 if ( $npLangs === '' ) {
706713 $npLangs = false;

Follow-up revisions

RevisionCommit summaryAuthorDate
r113005Use getLanguageNames since fetchLanguageNames is available only in 1.20+santhosh08:43, 5 March 2012

Comments

#Comment by Nikerabbit (talk | contribs)   07:53, 5 March 2012

fetchLanguageNames is only in 1.20 and later. Can also use isset instead of array_key_exists.

#Comment by Santhosh.thottingal (talk | contribs)   08:44, 5 March 2012

Used Language::getLanguageNames in r113005

Status & tagging log