Don't call isCompactLinksEnabled() twice in the same function

Store the result in a local variable.

Change-Id: Ie45c22c3af370b0cdcbe614497691b0bd849393f
This commit is contained in:
Fomafix
2021-11-21 18:58:39 +00:00
parent 7e34cf604b
commit c1a36d3490

View File

@@ -143,9 +143,10 @@ class UniversalLanguageSelectorHooks implements
// Soft dependency to Wikibase client. Don't enable CLL if links are managed manually. // Soft dependency to Wikibase client. Don't enable CLL if links are managed manually.
$excludedLinks = $out->getProperty( 'noexternallanglinks' ); $excludedLinks = $out->getProperty( 'noexternallanglinks' );
$override = is_array( $excludedLinks ) && in_array( '*', $excludedLinks ); $override = is_array( $excludedLinks ) && in_array( '*', $excludedLinks );
$isCompactLinksEnabled = $this->isCompactLinksEnabled( $out->getUser() );
$config = [ $config = [
'wgULSPosition' => $this->config->get( 'ULSPosition' ), 'wgULSPosition' => $this->config->get( 'ULSPosition' ),
'wgULSisCompactLinksEnabled' => $this->isCompactLinksEnabled( $out->getUser() ), 'wgULSisCompactLinksEnabled' => $isCompactLinksEnabled,
]; ];
// Load compact links if no mw-interlanguage-selector element is present in the page HTML. // Load compact links if no mw-interlanguage-selector element is present in the page HTML.
@@ -153,7 +154,7 @@ class UniversalLanguageSelectorHooks implements
// using the class as the heuristic. // using the class as the heuristic.
// Note if the element is rendered by the skin, its assumed that no collapsing is needed. // Note if the element is rendered by the skin, its assumed that no collapsing is needed.
// See T264824 for more information. // See T264824 for more information.
if ( !$override && $this->isCompactLinksEnabled( $out->getUser() ) && if ( !$override && $isCompactLinksEnabled &&
strpos( $out->getHTML(), 'mw-interlanguage-selector' ) === false strpos( $out->getHTML(), 'mw-interlanguage-selector' ) === false
) { ) {
$out->addModules( 'ext.uls.compactlinks' ); $out->addModules( 'ext.uls.compactlinks' );