IAlex has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/60248


Change subject: Simply the logic to decide whether to show "variant" and 
"noconvertlink" on Special:Preferences
......................................................................

Simply the logic to decide whether to show "variant" and "noconvertlink" on 
Special:Preferences

- Group common checks; $wgDisableLangConversion and count( $variants ) only be 
need to be
  executed once to decide to show or not both fields
- Move the check for existence of multiple variant directly after calling 
getVariants(),
  so there is no need to run unnecessary code when a language doesn't have 
variants
- Move the declaration of $variantArray to where it will actually be used
- fix comment style

Change-Id: I2d621424904d0210336845cd82f96bb68a022514
---
M includes/Preferences.php
1 file changed, 20 insertions(+), 21 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/48/60248/1

diff --git a/includes/Preferences.php b/includes/Preferences.php
index 44c87f0..7fcd499 100644
--- a/includes/Preferences.php
+++ b/includes/Preferences.php
@@ -310,23 +310,22 @@
                        'label-message' => 'yourlanguage',
                );
 
-               /* see if there are multiple language variants to choose from*/
-               $variantArray = array();
+               // see if there are multiple language variants to choose from
                if ( !$wgDisableLangConversion ) {
                        $variants = $wgContLang->getVariants();
 
-                       foreach ( $variants as $v ) {
-                               $v = str_replace( '_', '-', strtolower( $v ) );
-                               $variantArray[$v] = 
$wgContLang->getVariantname( $v, false );
-                       }
+                       if ( count( $variants ) > 1 ) {
+                               foreach ( $variants as $v ) {
+                                       $v = str_replace( '_', '-', strtolower( 
$v ) );
+                                       $variantArray[$v] = 
$wgContLang->getVariantname( $v, false );
+                               }
 
-                       $options = array();
-                       foreach ( $variantArray as $code => $name ) {
-                               $display = wfBCP47( $code ) . ' - ' . $name;
-                               $options[$display] = $code;
-                       }
+                               $options = array();
+                               foreach ( $variantArray as $code => $name ) {
+                                       $display = wfBCP47( $code ) . ' - ' . 
$name;
+                                       $options[$display] = $code;
+                               }
 
-                       if ( count( $variantArray ) > 1 ) {
                                $defaultPreferences['variant'] = array(
                                        'label-message' => 'yourvariant',
                                        'type' => 'select',
@@ -334,16 +333,16 @@
                                        'section' => 'personal/i18n',
                                        'help-message' => 'prefs-help-variant',
                                );
-                       }
-               }
 
-               if ( count( $variantArray ) > 1 && !$wgDisableLangConversion && 
!$wgDisableTitleConversion ) {
-                       $defaultPreferences['noconvertlink'] =
-                               array(
-                               'type' => 'toggle',
-                               'section' => 'personal/i18n',
-                               'label-message' => 'tog-noconvertlink',
-                       );
+                               if ( !$wgDisableTitleConversion ) {
+                                       $defaultPreferences['noconvertlink'] =
+                                               array(
+                                               'type' => 'toggle',
+                                               'section' => 'personal/i18n',
+                                               'label-message' => 
'tog-noconvertlink',
+                                       );
+                               }
+                       }
                }
 
                // show a preview of the old signature first

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I2d621424904d0210336845cd82f96bb68a022514
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: IAlex <coderev...@emsenhuber.ch>

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

Reply via email to