From 0b7ae1dce6a52d4709e3a133c38797a4d8a24de9 Mon Sep 17 00:00:00 2001 From: NikG Date: Thu, 4 Jan 2024 20:47:06 +0200 Subject: [PATCH] Avoid loading ext.uls.compactlinks module for Vector 2022 skin Bug: T353850 Change-Id: I43551be73da2126fd84ffaa0d37faec58bc47135 --- includes/Hooks.php | 16 +++++++++++++++- resources/js/ext.uls.interface.js | 9 +++++---- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/includes/Hooks.php b/includes/Hooks.php index d06737ae..3a86891b 100644 --- a/includes/Hooks.php +++ b/includes/Hooks.php @@ -97,6 +97,18 @@ class Hooks implements return (bool)$this->config->get( 'ULSEnable' ); } + /** + * Checks whether language is in header. + * + * @param Skin $skin + * @return bool + */ + private function isLanguageInHeader( Skin $skin ): bool { + $languageInHeaderConfig = $skin->getConfig()->get( 'VectorLanguageInHeader' ); + $userStatus = $skin->getUser()->isAnon() ? 'logged_out' : 'logged_in'; + return $languageInHeaderConfig[ $userStatus ] ?? true; + } + /** * Whether ULS Compact interlanguage links enabled * @@ -110,7 +122,7 @@ class Hooks implements return false; } if ( $skin->getSkinName() === 'vector-2022' ) { - return true; + return !$this->isLanguageInHeader( $skin ); } if ( $this->config->get( 'ULSCompactLanguageLinksBetaFeature' ) === true && $this->config->get( 'InterwikiMagic' ) === true && @@ -165,9 +177,11 @@ class Hooks implements $excludedLinks = $out->getProperty( 'noexternallanglinks' ); $override = is_array( $excludedLinks ) && in_array( '*', $excludedLinks, true ); $isCompactLinksEnabled = $this->isCompactLinksEnabled( $out->getUser(), $skin ); + $isVector2022LanguageInHeader = $skin->getSkinName() === 'vector-2022' && $this->isLanguageInHeader( $skin ); $config = [ 'wgULSPosition' => $this->config->get( 'ULSPosition' ), 'wgULSisCompactLinksEnabled' => $isCompactLinksEnabled, + 'wgVector2022LanguageInHeader' => $isVector2022LanguageInHeader ]; // Load compact links if no mw-interlanguage-selector element is present in the page HTML. diff --git a/resources/js/ext.uls.interface.js b/resources/js/ext.uls.interface.js index d52c76a9..2b153b6c 100644 --- a/resources/js/ext.uls.interface.js +++ b/resources/js/ext.uls.interface.js @@ -727,11 +727,12 @@ initPersonalEntryPoint(); } + // whether to load compact language links var compact = mw.config.get( 'wgULSisCompactLinksEnabled' ); - // The scope of the compact language links user preference has been expanded to also - // determine whether to show the omni box or not. Compact language links is already not - // loaded server side, so this is only relevant for the omnibox. - if ( compact ) { + // whether to show the omni box or not + var languageInHeader = mw.config.get( 'wgVector2022LanguageInHeader' ); + + if ( compact || languageInHeader ) { // Init compact languages OR omni selector using the mw-interlanguage-selector class initContentLanguageSelectorClickHandler(); } else {