Page MenuHomePhabricator

Fix "PHP Warning: count(): Parameter must be an array or Countable" in FlaggedRevs/backend/FRUserActivity.php
Closed, ResolvedPublic

Description

Hi, using php7.2 and mediawiki 1.31 i am getting this error:

  • "ErrorException from line 58 of /srv/mediawiki/w/extensions/FlaggedRevs/backend/FRUserActivity.php: PHP Warning: count(): Parameter must be an array or an object that implements Countable"

when using FlaggedRevs.

Event Timeline

Paladox created this task.Jun 4 2018, 9:26 PM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptJun 4 2018, 9:26 PM

Change 437364 had a related patch set uploaded (by Paladox; owner: Paladox):
[mediawiki/extensions/FlaggedRevs@master] Fix "count(): Parameter must be an array or an object that implements Countable"

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

Change 440670 had a related patch set uploaded (by Paladox; owner: Paladox):
[mediawiki/extensions/FlaggedRevs@REL1_31] Fix "count(): Parameter must be an array or an object that implements Countable"

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

Krinkle renamed this task from ErrorException from line 58 of /srv/mediawiki/w/extensions/FlaggedRevs/backend/FRUserActivity.php: PHP Warning: count(): Parameter must be an array or an object that implements Countable to Fix "PHP Warning: count(): Parameter must be an array or Countable" in FlaggedRevs/backend/FRUserActivity.php.Jun 16 2018, 5:43 PM

Change 440670 abandoned by Paladox:
Fix "count(): Parameter must be an array or an object that implements Countable"

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

@Johnywhy: https://phabricator.wikimedia.org/T182377 only lists files in MediaWiki core. This task is about code in the FlaggedRevs codebase. Why should it be related?

Johnywhy added a comment.EditedJun 26 2018, 12:21 AM

This task is about code in the FlaggedRevs codebase. Why should it be related?

Of course you're right, it can't be directly related, as it's a different code-base.

However, in the interest of looking for clues, i sometimes find it helpful to compare, when two different bits of code produce the same error message. Especially when both errors appeared with the same new 1.31 release. Maybe it there's a common cause? Maybe by solving one, we can solve the other.

It seems in DPL3, the issue is due to:

"in php 7.2 they changed count to only accept arrays or objects."
https://github.com/Alexia/DynamicPageList/issues/55

Could that be the issue here too?

The fix in DPL3, was to change if (count to if ( is_array. For example, here's a larger snippet from DPL3:

DPL3 Pre-1.31 Version:
if (count($this->mIncSecLabelsMatch) > $s && $this->mIncSecLabelsMatch[$s] != '....
DPL3 1.31 Patch
if ( is_array($this->mIncSecLabelsMatch) &&
   count($this->mIncSecLabelsMatch) > $s && $this->mIncSecLabelsMatch[$s] !=  '...

Could a similar fix work for this issue? I can't say. Just offering some ideas.

Vvjjkkii renamed this task from Fix "PHP Warning: count(): Parameter must be an array or Countable" in FlaggedRevs/backend/FRUserActivity.php to fnbaaaaaaa.Jul 1 2018, 1:06 AM
Vvjjkkii triaged this task as High priority.
Vvjjkkii updated the task description. (Show Details)
Vvjjkkii removed subscribers: gerritbot, Aklapper.
MacFan4000 renamed this task from fnbaaaaaaa to Fix "PHP Warning: count(): Parameter must be an array or Countable" in FlaggedRevs/backend/FRUserActivity.php.Jul 1 2018, 6:00 PM

Probably the same issue:

21:31:16 1) FRUserActivityTest::testPageIsUnderReview
21:31:16 count(): Parameter must be an array or an object that implements Countable
21:31:16 
21:31:16 /workspace/src/extensions/FlaggedRevs/backend/FRUserActivity.php:66
21:31:16 /workspace/src/extensions/FlaggedRevs/backend/FRUserActivity.php:77
21:31:16 /workspace/src/extensions/FlaggedRevs/tests/FRUserActivityTest.php:29
21:31:16 /workspace/src/maintenance/doMaintenance.php:94
21:31:16 
21:31:16 2) FRUserActivityTest::testDiffIsUnderReview
21:31:16 count(): Parameter must be an array or an object that implements Countable
21:31:16 
21:31:16 /workspace/src/extensions/FlaggedRevs/backend/FRUserActivity.php:127
21:31:16 /workspace/src/extensions/FlaggedRevs/backend/FRUserActivity.php:139
21:31:16 /workspace/src/extensions/FlaggedRevs/tests/FRUserActivityTest.php:43
21:31:16 /workspace/src/maintenance/doMaintenance.php:94
21:31:16 
21:31:16 3) FRUserActivityTest::testGetUserReviewingPage
21:31:16 count(): Parameter must be an array or an object that implements Countable
21:31:16 
21:31:16 /workspace/src/extensions/FlaggedRevs/backend/FRUserActivity.php:66
21:31:16 /workspace/src/extensions/FlaggedRevs/tests/FRUserActivityTest.php:56
21:31:16 /workspace/src/maintenance/doMaintenance.php:94
21:31:16 
21:31:16 4) FRUserActivityTest::testGetUserReviewingDiff
21:31:16 count(): Parameter must be an array or an object that implements Countable
21:31:16 
21:31:16 /workspace/src/extensions/FlaggedRevs/backend/FRUserActivity.php:127
21:31:16 /workspace/src/extensions/FlaggedRevs/tests/FRUserActivityTest.php:78
21:31:16 /workspace/src/maintenance/doMaintenance.php:94

https://integration.wikimedia.org/ci/job/quibble-vendor-mysql-php72-docker/168/consoleFull

Change 437364 merged by jenkins-bot:
[mediawiki/extensions/FlaggedRevs@master] Fix "count(): Parameter must be an array or an object that implements Countable"

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

Krinkle closed this task as Resolved.Oct 14 2018, 3:03 AM
Krinkle claimed this task.

Change 440670 restored by Reedy:
Fix "count(): Parameter must be an array or an object that implements Countable"

Reason:
Un-abandoning as master patch is merged to allow lazy gerrit cherry pick

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

Change 467324 had a related patch set uploaded (by Reedy; owner: Paladox):
[mediawiki/extensions/FlaggedRevs@REL1_30] Fix "count(): Parameter must be an array or an object that implements Countable"

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

Change 467326 had a related patch set uploaded (by Reedy; owner: Paladox):
[mediawiki/extensions/FlaggedRevs@REL1_27] Fix "count(): Parameter must be an array or an object that implements Countable"

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

Change 440670 merged by jenkins-bot:
[mediawiki/extensions/FlaggedRevs@REL1_31] Fix "count(): Parameter must be an array or an object that implements Countable"

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

Change 467326 merged by Umherirrender:
[mediawiki/extensions/FlaggedRevs@REL1_27] Fix "count(): Parameter must be an array or an object that implements Countable"

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

Change 467324 merged by Umherirrender:
[mediawiki/extensions/FlaggedRevs@REL1_30] Fix "count(): Parameter must be an array or an object that implements Countable"

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