Page MenuHomePhabricator

Refreshed running on PHP >=7.2 yields page-breaking warning if MediaWiki:Refreshed-wiki-dropdown is empty
Closed, ResolvedPublic

Description

(I have a fix ready, I'm making a task for record purposes.)

When MediaWiki is running on PHP 7.2 or above, and MediaWiki:Refreshed-wiki-dropdown is empty, Refreshed will render incorrectly. Specifically you get the warning "Warning: count(): Parameter must be an array or an object that implements Countable [...]." This breaks the page.

This is because per the count() docs, as of PHP 7.2, count() yields a warning when an element is passed in that's not an array or Countable. (This issue hasn't popped up on sites like Brickimedia since they use older versions of PHP.) The culprit is this line in RefreshedTemplate.php:

wfDebugLog( 'Refreshed', sprintf( 'Get %s, which contains %s lines', $messageKey, count( $lines ) ) );

$lines is sometimes null, which is not an array or Countable. Specifically it's null when MediaWiki:Refreshed-wiki-dropdown is empty. Then $count( $lines ) yields a warning, breaking the page.

To fix this issue, a check should be added to RefreshedTemplate.php to see if $lines is null before the above line is run.

Event Timeline

Change 445850 had a related patch set uploaded (by MtMNC; owner: MtMNC):
[mediawiki/skins/Refreshed@master] Fix T199637, increment version number

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

Change 445850 merged by jenkins-bot:
[mediawiki/skins/Refreshed@master] Fix T199637, increment version number

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