count(): Parameter must be an array or an object that implements Countable
-
When running PHP 7.4, I get the following warning on the logs:
PHP Warning: count(): Parameter must be an array or an object that implements Countable
This is tied to line 302 of
feedwordpress/syndicatedlink.class.php
(at least on version 2017.1020.), which goesif (count($tombstones) > 0) :
Now, when the variable
$tombstones
is, for example, aNULL
, this will fail becauseNULL
is neither an array nor an object. Earlier versions of PHP would equate any sort of error to the value zero (orFALSE
), which meant you could be a little more careless about checks such as the above one. Contemporary versions of PHP are more demanding, even if they will often just throw a warning and not an error. In this case, a simple fix is to change line 302 to:if (is_countable($tombstones) && count($tombstones) > 0) :
is_countable()
has been introduced in PHP 7.3 exactly for this purpose.Possibly there are more instances like this in the rest of the code, but, for now, this easily fixes the warning (and makes it future-proof if the PHP developers decide to turn this particular warning into a fatal error, which they are prone to do over time…).
FeedWordPress has few updates (it simply works…), but perhaps one of these days the developers of this fantastic plugin might make this small correction. Thanks!
- The topic ‘count(): Parameter must be an array or an object that implements Countable’ is closed to new replies.