Phpmyadmin - Count(): Parameter Must Be an Array or an Object That Implements Countable

Phpmyadmin export issue: count(): Parameter must be an array or an object that implements Countable

It seems we can't remove all the issues from PhpMyAdmin with PHP 7.2+. But we can remove this issue by change in one line in file libraries/plugin_interface.lib.php file at line no 532.

Below is the screenshot for the fix.

Before fix code looks like:-

Sample Image

After fix code looks like:-

Sample Image

Above is the only fix to solve error messages in export database screen.

Trying to update to PHP 7.4 but getting this error in an element, Warning: count(): Parameter must be an array or an object that implements Countable

from the WordPress documentation about get_the_terms :

Return: Array of WP_Term objects on success, false, if there are no terms or the post, does not exist, WP_Error on failure.

that means get_the_terms function will return 1 of these 3 options :

  1. false
  2. error
  3. array

if the post has some "terms" then you will get no warnings, but it occurs when you try to count some results that are not a valid array (or any countable object).
so you can check for it befor you try to count the fetched terms :

if(is_array($type_terms))
$type_count = count($type_terms);
else
$type_count = [];

or with ternary operation:

$type_count = is_array($type_terms) ? count($type_terms); : [] ;


Related Topics



Leave a reply



Submit