From e5e188fbc6b5b46fbd8317d1eca42724aecb21b5 Mon Sep 17 00:00:00 2001 From: Ammar Abdulhamid Date: Thu, 25 Jun 2020 16:18:45 +0100 Subject: [PATCH] Fix lang portlet header display. Timeless is showing the language portlet correctly when are languages or when something is added to the portlet, but it's also showing the header even if there are no languages and nothing extra was defined. The root cause is that when we check $this->afterLangPortlet !== '', the property is actually null at that stage, it is only defined when we call $this->getPortlet( 'lang' ...) in the next line. Bug: T256355 Change-Id: Ie3e0acccede7e2f477c6182e288def8d7a35070e --- includes/TimelessTemplate.php | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/includes/TimelessTemplate.php b/includes/TimelessTemplate.php index 68e4445..bec7ebe 100644 --- a/includes/TimelessTemplate.php +++ b/includes/TimelessTemplate.php @@ -954,7 +954,6 @@ class TimelessTemplate extends BaseTemplate { $html = ''; $variants = ''; $otherprojects = ''; - $languages = ''; $show = false; $variantsOnly = false; @@ -966,20 +965,18 @@ class TimelessTemplate extends BaseTemplate { $show = true; $variantsOnly = true; } - if ( $this->sidebar['LANGUAGES'] !== false || - // Force rendering of this section if the 'lang' portlet has - // been modified by hook even if there are no language items. - //$this->getAfterPortlet( 'lang' ) !== '' - $this->afterLangPortlet !== '' - ) { - $languages = $this->getPortlet( - 'lang', - $this->languages ?: [], - 'otherlanguages' - ); + + $languages = $this->getPortlet( 'lang', $this->languages, 'otherlanguages' ); + + // Force rendering of this section if there are languages or when the 'lang' + // portlet has been modified by hook even if there are no language items. + if ( count( $this->languages ) || $this->afterLangPortlet !== '' ) { $show = true; $variantsOnly = false; + } else { + $languages = ''; } + // if using wikibase for 'in other projects' if ( isset( $this->otherProjects ) ) { $otherprojects = $this->getPortlet(