I get the following warning about this module whenever I run a Drush command:

count(): Parameter must be an array or an object that implements Countable antispam.module:1545

My setup is as follows:
Drupal 7.58
PHP 7.2.2
Zend Engine v3.2.0, with Zend OPcache v7.2.2
Ubuntu 16.04.3
mysql 5.7.21

The code is within the antispam_user_load() function. It does not check if $moderator_types is an array or object before doing a count().

I will try to roll a patch for this later today.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

peterhebert created an issue. See original summary.

peterhebert’s picture

Issue summary: View changes
peterhebert’s picture

peterhebert’s picture

Status: Needs work » Needs review
djdevin’s picture

Version: 7.x-1.6 » 7.x-1.x-dev
FileSize
506 bytes

Same thing, one less line by fixing it at the source.

Status: Needs review » Needs work

The last submitted patch, 5: 2957097-define-array-antispam.patch, failed testing. View results

djdevin’s picture

Status: Needs work » Needs review
FileSize
438 bytes

Status: Needs review » Needs work

The last submitted patch, 7: 2957097-define-array-antispam.patch, failed testing. View results

bgm’s picture

Patch in #7 works for me. Thank you!

junaidpv’s picture

Status: Needs work » Needs review
FileSize
643 bytes

#7 may not work well as it may cause to empty already populated array.

Here is improved one.

laurelstreng’s picture

Tested the patch provided by junaidpv in #10 and it is working for me – antispam-ensure-moderator_types-is-array-2957097-10.patch

My setup:
Drupal 7.67
PHP 7.2
Ubuntu 16.04
mysql 5.7.26

I was running into the following warning about this module whenever I ran a Drush command as well as in the database logs:
Drush warning: count(): Parameter must be an array or an object that implements Countable antispam.module:1545
DB Logs warning: Warning: count(): Parameter must be an array or an object that implements Countable in antispam_user_load() (line 1545 of /docroot/sites/all/modules/contrib/antispam/antispam.module).

1. Applied the patch by placing the patch in the same directory as the file being patched and run the patch command: patch < file.patch
2. Ran cron, cleared the site cache using drush, and checked the database logging /admin/reports/dblog
3. No longer seeing the warning when running drush commands
4. No longer seeing the warning in the database logs

laurelstreng’s picture

Status: Needs review » Reviewed & tested by the community