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.
The warning below is triggered on PHP 7.2 or later.
[warning] count(): Parameter must be an array or an object that implements Countable Api.php:357
Comment | File | Size | Author |
---|---|---|---|
#8 | interdiff-6-8.txt | 1013 bytes | dscl |
#8 | 3023929-count-parameter-must-be-countable-D8-8.patch | 550 bytes | dscl |
#6 | 3023929-fastly_compatibility_with_php7.2.patch | 1015 bytes | LEalex |
#2 | fastly_compatibility_with_php7.2_3023929.patch | 989 bytes | Eugene Bsk |
Comments
Comment #2
Eugene Bsk CreditAttribution: Eugene Bsk commentedHere is the patch.
Could someone please review it.
Comment #3
gg4 CreditAttribution: gg4 commentedFor reference: http://php.net/manual/en/migration72.incompatible.php
Comment #4
gg4 CreditAttribution: gg4 commentedPatch LGTM and applies fine.
Comment #5
markdorisonPatch works as expected. RTBC++.
Comment #6
LEalex CreditAttribution: LEalex commentedi still have problems (sometimes), here's the fix (based #2) thats works for me
Comment #7
gg4 CreditAttribution: gg4 commentedThanks, @LEalex. You missed you pieces of #2 and please provide and interdiff of changes between patches.
Comment #8
dscl CreditAttribution: dscl at DevBrains, Digital Garden commentedThere is no reason for changing the
json()
method to make it return associative arrays, specially because in that same file, at line 276, the result is referenced as an object.And, as far as I can tell, the addition from #6 is the actual fix for the issue given that is was caused because
json_decode()
is returningnull
. The other 2 possible returns are countable, so we just need to make sure we don't let thenull
value get intocount()
.Still, considering the fact we are testing
count() > 0
, it would be simpler to just useempty()
instead as it would cover all scenarios.Pushing a new patch with the intediff to #6.
Comment #9
dman CreditAttribution: dman at Platform.sh commentedAye. No need to change the json_decode() call that I can see.
empty() is usually the most concise way to make warnings like this go away, I agree.
Comment #11
vvuksan-fastly CreditAttribution: vvuksan-fastly commentedFixed in 8.x-3.x-dev. Will be released in 8.x-3.8
Comment #12
vvuksan-fastly CreditAttribution: vvuksan-fastly commented