Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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.
Comment | File | Size | Author |
---|---|---|---|
#10 | antispam-ensure-moderator_types-is-array-2957097-10.patch | 643 bytes | junaidpv |
|
Comments
Comment #2
peterhebert CreditAttribution: peterhebert commentedComment #3
peterhebert CreditAttribution: peterhebert at Rex Rana commentedPlease find patch attached.
Comment #4
peterhebert CreditAttribution: peterhebert at Rex Rana commentedComment #5
djdevinSame thing, one less line by fixing it at the source.
Comment #7
djdevinComment #9
bgm CreditAttribution: bgm commentedPatch in #7 works for me. Thank you!
Comment #10
junaidpv#7 may not work well as it may cause to empty already populated array.
Here is improved one.
Comment #11
laurelstreng CreditAttribution: laurelstreng commentedTested 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
Comment #12
laurelstreng CreditAttribution: laurelstreng commented