Page MenuHomePhabricator

SkinComponentFooter tries to call ->getTemplateData() on an empty array if no footer icons are set
Closed, ResolvedPublicBUG REPORT

Description

Steps to replicate the issue (include links if applicable):

  • set $wgFooterIcons['poweredby'] = []; (or alternatively unset( $wgFooterIcons['poweredby'] ); )

What happens?:

Exception caught inside exception handler: [615d37364551b65845ff1768] /w/index.php/Main_Page Error: Call to a member function getTemplateData() on array
Backtrace:
from /var/www/html/w/includes/skins/components/SkinComponentFooter.php(319)
#0 /var/www/html/w/includes/skins/components/SkinComponentFooter.php(76): MediaWiki\Skin\SkinComponentFooter->getFooterIcons()
#1 /var/www/html/w/includes/skins/Skin.php(195): MediaWiki\Skin\SkinComponentFooter->getTemplateData()
#2 /var/www/html/w/includes/skins/SkinTemplate.php(180): Skin->getTemplateData()
#3 /var/www/html/w/includes/skins/SkinMustache.php(125): SkinTemplate->getTemplateData()
#4 /var/www/html/w/skins/Vector/includes/SkinVectorLegacy.php(161): SkinMustache->getTemplateData()
#5 /var/www/html/w/includes/skins/SkinMustache.php(92): MediaWiki\Skins\Vector\SkinVectorLegacy->getTemplateData()
#6 /var/www/html/w/includes/skins/SkinTemplate.php(173): SkinMustache->generateHTML()
#7 /var/www/html/w/includes/OutputPage.php(2922): SkinTemplate->outputPage()
#8 /var/www/html/w/includes/exception/MWExceptionRenderer.php(185): OutputPage->output()
#9 /var/www/html/w/includes/exception/MWExceptionRenderer.php(103): MWExceptionRenderer::reportHTML()
#10 /var/www/html/w/includes/exception/MWExceptionHandler.php(133): MWExceptionRenderer::output()
#11 /var/www/html/w/includes/exception/MWExceptionHandler.php(250): MWExceptionHandler::report()
#12 /var/www/html/w/includes/MediaWiki.php(616): MWExceptionHandler::handleException()
#13 /var/w

What should have happened instead?:
No icons should be output, like in 1.39 and earlier

Software version (skip for WMF-hosted wikis like Wikipedia):
master (1.41alpha). MediaWiki 1.40

Other information (browser name/version, screenshots, etc.):

The code logic looks broken.

$dataIcons = []; 
$skinContext = $this->skinContext;
// If footer icons are enabled append to the end of the rows
$footerIcons = $skinContext->getFooterIcons();

if ( count( $footerIcons ) > 0 ) { 
          /* omitting since this branch is false */
}

return $dataIcons->getTemplateData();

So we try and call the getTemplateData() method on an array. I'm honestly fairly surprised that phan was ok with this.

Note: original report at https://www.mediawiki.org/wiki/Topic:Xnavpi1193orte6z

Event Timeline

Change 947002 had a related patch set uploaded (by Ammarpad; author: Ammarpad):

[mediawiki/core@master] skins: Avoid function call on array

https://gerrit.wikimedia.org/r/947002

Change 947002 merged by jenkins-bot:

[mediawiki/core@master] skins: Avoid function call on array

https://gerrit.wikimedia.org/r/947002

Change 947453 had a related patch set uploaded (by Brian Wolff; author: Ammarpad):

[mediawiki/core@REL1_40] skins: Avoid function call on array

https://gerrit.wikimedia.org/r/947453

Bawolff assigned this task to Ammarpad.

Should be included in 1.40.1

Change 947453 merged by jenkins-bot:

[mediawiki/core@REL1_40] skins: Avoid function call on array

https://gerrit.wikimedia.org/r/947453