Bartosz Dziewoński has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/370874 )

Change subject: Skip duplicate deprecated language codes in the language 
dropdown
......................................................................

Skip duplicate deprecated language codes in the language dropdown

LanguageCode::getDeprecatedCodeMapping() is a very convenient function
recently introduced in MW 1.29.

This check is added at the end because we have to check the template
existence first - if the wiki has e.g. a Template:Be-x-old, but not
Template:Be-tarask, we don't want to hide the be-x-old.

Bug: T172220
Change-Id: I71d266eee205d2201772e903cb0bcb06bf567b2f
---
M UploadWizard.config.php
1 file changed, 10 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/UploadWizard 
refs/changes/74/370874/1

diff --git a/UploadWizard.config.php b/UploadWizard.config.php
index 09cda85..79fc662 100644
--- a/UploadWizard.config.php
+++ b/UploadWizard.config.php
@@ -9,7 +9,8 @@
 
 $userLangCode = $wgLang->getCode();
 // We need to get a list of languages for the description dropdown.
-$cacheKey = wfMemcKey( 'uploadwizard', 'language-templates', $userLangCode );
+// Increase the number below to invalidate the cache if this code changes.
+$cacheKey = wfMemcKey( 'uploadwizard', 'language-templates2', $userLangCode );
 // Try to get a cached version of the list
 $uwLanguages = $wgMemc->get( $cacheKey );
 // Commons only: ISO 646 code of Tagalog is 'tl', but language template is 
'tgl'
@@ -54,6 +55,14 @@
                        }
                }
        }
+
+       // Skip the duplicate deprecated language codes if the new one is okay 
to use.
+       foreach ( LanguageCode::getDeprecatedCodeMapping() as $oldKey => 
$newKey ) {
+               if ( isset( $uwLanguages[$newKey] ) && isset( 
$uwLanguages[$oldKey] ) ) {
+                       unset( $uwLanguages[$oldKey] );
+               }
+       }
+
        // Sort the list by the language name
        natcasesort( $uwLanguages );
        // Cache the list for 1 day

-- 
To view, visit https://gerrit.wikimedia.org/r/370874
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I71d266eee205d2201772e903cb0bcb06bf567b2f
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/UploadWizard
Gerrit-Branch: master
Gerrit-Owner: Bartosz Dziewoński <matma....@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to