Page MenuHomePhabricator

[Scribunto] Warning: count(): Parameter must be an array or an object that implements Countable in PHP 7.2
Closed, ResolvedPublic

Description

Today, I upgraded php7.1 to php7.2. In calling Lua module page show many same Warning:

Warning: count(): Parameter must be an array or an object that implements Countable in /InstallPath/w/extensions/Scribunto/engines/LuaStandalone/LuaStandaloneEngine.php on line 456

I think this is because Scribunto extension is not compatible with php7.2.
My wiki info are:

MediaWiki1.29.1
PHP7.2.0 (cgi-fcgi)
MariaDB10.2.11-MariaDB-log
ICU52.1
Lua5.1.5

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald TranscriptDec 2 2017, 4:13 PM
RazeSoldier renamed this task from [Scribunto] Warning: count(): Parameter must be an array or an object that implements Countable to [Scribunto] Warning: count(): Parameter must be an array or an object that implements Countable in PHP 7.2.Dec 2 2017, 4:16 PM
RazeSoldier updated the task description. (Show Details)
RazeSoldier updated the task description. (Show Details)Dec 2 2017, 4:41 PM
RazeSoldier added a comment.EditedDec 2 2017, 5:35 PM

I found in the official manual why this warning occurred.

An E_WARNING will now be emitted when attempting to count() non-countable types (this includes the sizeof() alias function).

Restricted Application added a subscriber: TerraCodes. · View Herald TranscriptDec 3 2017, 4:47 PM
Anomie added a subscriber: Anomie.Dec 4 2017, 3:40 PM

I think this is because Scribunto extension is not compatible with php7.2.

It's because PHP 7.2 decided to break useful existing behavior.

Change 395023 had a related patch set uploaded (by Anomie; owner: Anomie):
[mediawiki/extensions/Scribunto@master] Avoid passing null to count()

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

Change 395023 merged by jenkins-bot:
[mediawiki/extensions/Scribunto@master] Avoid passing null to count()

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

Anomie closed this task as Resolved.Dec 4 2017, 6:51 PM
Anomie claimed this task.

Note you'll need to update your MediaWiki installation to get the fix, or backport the change yourself if you want to continue using PHP 7.2 with older versions of MediaWiki.