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.
After updating to PHP 7.2 from PHP 7.0 the following warning is shown when using Devel:
Warning: count(): Parameter must be an array or an object that implements Countable in krumo::_object() (line 1123 of /var/aegir/platforms/drupal-7.58/sites/SITE/modules/devel/krumo/class.krumo.php).
Maybe the core 7.2 compatibility patch #2947772: Fully support PHP 7.2 in Drupal 7 or the Drupal 8 issue #2951821: Warning: count(): Parameter must be an array could help?
Comment | File | Size | Author |
---|---|---|---|
#6 | devel-php72-count-bugs-2959508-6-D7.patch | 2.4 KB | salvis |
|
Comments
Comment #2
salvisYes, count() expects an array. I don't think the Countable interface is a consideration here.
I also found another instance of count() potentially getting a non-array, as well as an undefined index, both outside of krumo, but related to dpm() et al.
Comment #3
salvisAfter giving this some more thought, here's an improved patch.
Comment #4
NWOM CreditAttribution: NWOM commented#3 worked great and applied cleanly. Thank you very much!
Comment #6
salvisRe-rolled after committing #2855666: Make Krumo compatible with XSS injection protection to drupal_set_message().
Comment #8
salvisComment #10
MustangGB CreditAttribution: MustangGB commentedSo this has added
is_array()
, I'm wondering if instead we should be duplicating the code frommerits_krumo()
and using(is_object($input) || is_array($input))
instead?Comment #11
salvisGiven
is_object($input) == TRUE
, how likely is it that $input implements Countable? And even if it does, what would this give to us?Granted, the patch is on the efficient side rather than on the sophisticated side, but do you see any relevant use case for change?
Comment #12
coozila CreditAttribution: coozila commentedanother error similar to the latest version drupal 7.9+ php 7.4-fpm + nginx and memcached server:
Warning: count(): Parameter must be an array or an object that implements Countable in _object() (line 1111 of /var/www/mysite.com/web/sites/all/modules/devel/krumo/class.krumo.php).
this error is always present in the logs even though everything is updated with the composer, any suggestion is welcome