Use $lang->hasVariants() instead of count( $lang->getVariants() ) > 1

Change-Id: I23668c69a8d8cc886168cbbd4f94cf13b597b5a6
This commit is contained in:
Fomafix 2018-07-03 22:14:06 +02:00 committed by Umherirrender
parent 6cce704da1
commit 88f469624d
5 changed files with 8 additions and 9 deletions

View file

@ -90,7 +90,7 @@ class MediaWiki {
}
// Check variant links so that interwiki links don't have to worry
// about the possible different language variants
if ( count( $wgContLang->getVariants() ) > 1
if ( $wgContLang->hasVariants()
&& !is_null( $ret ) && $ret->getArticleID() == 0
) {
$wgContLang->findVariantLink( $title, $ret );

View file

@ -1200,7 +1200,7 @@ class ApiPageSet extends ApiBase {
// Variants checking
global $wgContLang;
if ( $this->mConvertTitles &&
count( $wgContLang->getVariants() ) > 1 &&
$wgContLang->hasVariants() &&
!$titleObj->exists()
) {
// Language::findVariantLink will modify titleText and titleObj into

View file

@ -444,12 +444,11 @@ class DefaultPreferencesFactory implements PreferencesFactory {
if ( !$this->config->get( 'DisableLangConversion' ) ) {
foreach ( LanguageConverter::$languagesWithVariants as $langCode ) {
if ( $langCode == $this->contLang->getCode() ) {
$variants = $this->contLang->getVariants();
if ( count( $variants ) <= 1 ) {
if ( !$this->contLang->hasVariants() ) {
continue;
}
$variants = $this->contLang->getVariants();
$variantArray = [];
foreach ( $variants as $v ) {
$v = str_replace( '_', '-', strtolower( $v ) );

View file

@ -1116,11 +1116,11 @@ class SkinTemplate extends Skin {
if ( $userCanRead && !$wgDisableLangConversion ) {
$pageLang = $title->getPageLanguage();
// Gets list of language variants
$variants = $pageLang->getVariants();
// Checks that language conversion is enabled and variants exist
// And if it is not in the special namespace
if ( count( $variants ) > 1 ) {
if ( $pageLang->hasVariants() ) {
// Gets list of language variants
$variants = $pageLang->getVariants();
// Gets preferred variant (note that user preference is
// only possible for wiki content language variant)
$preferred = $pageLang->getPreferredVariant();

View file

@ -42,7 +42,7 @@ class ListVariants extends Maintenance {
$variants = [];
foreach ( LanguageConverter::$languagesWithVariants as $langCode ) {
$lang = Language::factory( $langCode );
if ( count( $lang->getVariants() ) > 1 ) {
if ( $lang->hasVariants() ) {
$variants += array_flip( $lang->getVariants() );
$variantLangs[$langCode] = $lang->getVariants();
}