Page MenuHomePhabricator

TemplateData emits count() parameter warning on PHP7.2
Closed, ResolvedPublic

Description

MediaWiki: 1.31
PHP: 7.2
We have TemplateData installed and run PHP 7.2, but there is a compatibility issue with PHP 7.2 when executing functions. It should be fixed so that it can also be compatible with the latest PHP 7.2

[16-Aug-2018 17:38:30 UTC] PHP Warning:  count(): Parameter must be an array or an object that implements Countable in /srv/mediawiki/w/extensions/TemplateData/                                                                                        api/ApiTemplateData.php on line 133
2018-08-16 17:38:38 mw1 oryzawiki: [87d4a45713e389a945f81587] /w/api.php?format=json&action=templatedata&doNotIgnoreMissingTitles=1&titles=Template%3ATrack%20listing   ErrorException from line 133 of /srv/mediawiki/w/extensions/TemplateData/api/ApiTemplateData.php: PHP Warning: count(): Parameter must be an array or an object that implements Countable
#0 /srv/mediawiki/w/extensions/TemplateData/api/ApiTemplateData.php(133): MWExceptionHandler::handleError(integer, string, string, integer, array)
#1 /srv/mediawiki/w/includes/api/ApiMain.php(1579): ApiTemplateData->execute()
#2 /srv/mediawiki/w/includes/api/ApiMain.php(535): ApiMain->executeAction()
#3 /srv/mediawiki/w/includes/api/ApiMain.php(506): ApiMain->executeActionWithErrorHandling()
#4 /srv/mediawiki/w/api.php(94): ApiMain->execute()
#5 {main}
[16-Aug-2018 17:38:38 UTC] PHP Warning:  count(): Parameter must be an array or an object that implements Countable in /srv/mediawiki/w/extensions/TemplateData/                                                                                        api/ApiTemplateData.php on line 133

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald TranscriptAug 16 2018, 6:11 PM
Restricted Application added a project: VisualEditor. · View Herald TranscriptAug 16 2018, 6:46 PM
MaxSem updated the task description. (Show Details)Sep 11 2018, 7:32 PM
Krinkle renamed this task from count() parameter in TemplateData not PHP7.2 compatible to TemplateData emites count() parameter warning on PHP7.2.Oct 14 2018, 2:43 AM
Krinkle renamed this task from TemplateData emites count() parameter warning on PHP7.2 to TemplateData emits count() parameter warning on PHP7.2.

Rephrase summary. This is not an incompatibility, but a deprecation warning. In PHP 7.2, count() still works and behaves the same as before, which is that null counts as 0, and values that are not arrays or countable, are counted as 1, similar to if they were wrapped in an array.

Change 467107 had a related patch set uploaded (by Krinkle; owner: Krinkle):
[mediawiki/extensions/TemplateData@master] ApiTemplateData: Address non-array count() warning on PHP 7.2

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

Krinkle claimed this task.Oct 14 2018, 2:56 AM
Krinkle added a project: Performance-Team.
Krinkle triaged this task as High priority.Oct 14 2018, 9:34 PM

Change 467107 merged by jenkins-bot:
[mediawiki/extensions/TemplateData@master] ApiTemplateData: Address non-array count() warning on PHP 7.2

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

Restricted Application added a project: User-Ryasmeen. · View Herald TranscriptOct 15 2018, 5:20 PM

Change 467433 had a related patch set uploaded (by Paladox; owner: Krinkle):
[mediawiki/extensions/TemplateData@REL1_31] ApiTemplateData: Address non-array count() warning on PHP 7.2

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

Change 467433 merged by jenkins-bot:
[mediawiki/extensions/TemplateData@REL1_31] ApiTemplateData: Address non-array count() warning on PHP 7.2

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