radgeek/feedwordpress

new PHP error

Closed this issue · 3 comments

updated feedwordpress with the resent patch fix

all old errors are gone apart from 1 error

Got error 'PHP message: PHP Warning: count(): Parameter must be an array or an object that implements Countable in /var/www/wp-content/plugins/feedwordpress/syndicatedpost.class.php on line 708\n

running :
wordpress 5.3.2
PHP 7.2.26
mysql 8.0.18
Apache 2.4.41

syndicatedpost.class.php fix ??

is_countable() has been introduced in PHP 7.3

line 708 can be change from

if (count($aa) > 0) :

change to

if (is_countable($aa) && count($aa) > 0) :

line 906

if (count($refs) > 0) :

change to

if (is_countable($refs) && count($refs) > 0) :

line 1304

if (count($seen) > 0) :

change to

if (is_countable($seen) && count($seen) > 0) :

@talgalili : Fortunately not. Only PHP 7.3+ provides is_countable() as a native function. But the WordPress core from WP 4.9.6 onward provides it by means of a polyfill function when running under earlier versions of PHP. (Check out wp-includes/compat.php.) I availed myself of the GPL and have also copied over the function from WordPress 4.9.6+ into FWP's compatability.php module, so that it will also be available on versions of WordPress < 4.9.6. So -- hopefully -- it should be possible to use it where convenient, without trashing backward compatibility. (Consequently, I have also adopted @bigalownz 's suggested changes in the commit above.)