Open trollkotze opened 5 years ago
Changing the line
if($val == '' || !count($val)) continue;
to
if($val == '' || is_null($val) || (is_array($val) && count($val) == 0)) continue;
seems to be a valid workaround.
Can you send a pull request?
Okay, I did. Just am not completely sure if that is all there is to it, just my particular use-case does not print a warning anymore.
Oh, and it seems Travis CI fails for all 7.x PHP versions. But not showing what exactly fails, which lines of code are wrong. I suspect it might be just because of other similar cases where some instructions were too laissez-faire for PHP 7.x.
Had the same issue with the discussions plugin - line 425 in action.php (docuwiki/lib/plugins/discussion) $cnt = count($data['comments'])
is changed to:
if($data['comments'] == '' || is_null($data['comments']) || (is_array($data['comments']) && count($data['comments']) == 0)) {
$cnt = 0;
} else {
$cnt = count($data['comments']);
}
Same story here. Waiting for a verified solution. The workaround above is welcome.
Hello!
Since upgrading a server to PHP 7.3 (only from PHP 7.1 I believe?) there appear now warning messages
for adminsnot only for admins, apparently stemming from code in the Data plugin:Warning: count(): Parameter must be an array or an object that implements Countable in /xxx/yyy/zzz/lib/plugins/data/syntax/entry.php on line 168
I am not an expert in PHP and the new stricter type checks that seems to have been introduced. But here is the code where it happens:Not sure what this $data array contains, but it seems PHP 7.3. is warning that it may be of some type for which
count(...)
is not applicable.Probably this is just one small instance of possibly more scenarios where PHP 7.3 does some stricter checking than previous PHP versions.
Since it's only putting out "warning", I assume that nothing is really broken by it. But it might be worthwhile to see how to satisfy PHP 7.3 overall.