From d56792addb8464997772b566db71a78c39e5cf30 Mon Sep 17 00:00:00 2001 From: Timo Tijhof Date: Tue, 2 Apr 2019 19:42:01 +0100 Subject: [PATCH] Fix

to be present even if title is "0" Regression from 74b9803d9abc47, caused by a bug in LightNCandy which caused {{foo}} to render "0", and {{#foo}} to pass as true with "0", but then in {{#foo}}{{foo}}{{/foo} render as empty string producing "". In other words, the conditional is passing and the inner block is executed, but the placeholder is mistakenly converting "0" => null => "" (empty string), causing the

to render but without any text in it. Work around this bug by simply removing the conditional. Several other skins already don't have this conditional and it's unclear why or in what situation MediaWiki would send OutputPage to SkinTemplate without a title. I think it would make sense in such rare case to still have a consistent layout for extensions and gadgets to interact with and not omit the H1 element, but render it with the value that OutputPage gave it, even if it is the empty string. Bug: T219864 Change-Id: I6e04b512d2fe2e949ff5385cb38ceebe392fb255 --- includes/VectorTemplate.php | 5 +++-- includes/templates/index.mustache | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/includes/VectorTemplate.php b/includes/VectorTemplate.php index 737e1026..faedcfe4 100644 --- a/includes/VectorTemplate.php +++ b/includes/VectorTemplate.php @@ -62,8 +62,9 @@ class VectorTemplate extends BaseTemplate { 'page-langcode' => $this->getSkin()->getTitle()->getPageViewLanguage()->getHtmlCode(), 'page-isarticle' => (bool)$this->data['isarticle'], - // Loose comparison with '!=' is intentional, to catch null and false too, but not '0' - 'html-title' => ( $this->data['title'] != '' ? $this->get( 'title' ) : null ), + // Remember that the string '0' is a valid title. + // From OutputPage::getPageTitle, via ::setPageTitle(). + 'html-title' => $this->get( 'title', '' ), 'html-prebodyhtml' => $this->get( 'prebodyhtml', '' ), 'msg-tagline' => $this->getMsg( 'tagline' )->text(), diff --git a/includes/templates/index.mustache b/includes/templates/index.mustache index 4f8a6d74..e5847324 100644 --- a/includes/templates/index.mustache +++ b/includes/templates/index.mustache @@ -5,7 +5,7 @@ {{#html-sitenotice}}
{{{html-sitenotice}}}
{{/html-sitenotice}} {{{html-indicators}}} - {{#html-title}}

{{{html-title}}}

{{/html-title}} +

{{{html-title}}}

{{{html-prebodyhtml}}}
{{#page-isarticle}}
{{msg-tagline}}
{{/page-isarticle}}