Jump to content

Welcome, Guest!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

  • 0
ukclearance

PHP errors - Parameter must be an array or an object that implements Countable

Question

I looked in the log files of my server and noticed that there are the following warnings: ```

PHP Warning: count(): Parameter must be an array or an object that implements Countable in /home/30b/classes/Blowfish.php on line 80] PHP Warning: count(): Parameter must be an array or an object that implements Countable in /home/30b/classes/controller/AdminController.php on line 4098 PHP Warning: count(): Parameter must be an array or an object that implements Countable in /home/30b/classes/controller/AdminController.php on line 3245 PHP Warning: count(): Parameter must be an array or an object that implements Countable in /home/30b/classes/Cart.php on line 1718

``` Are these errors going to cause problems with my store and how to I fix them. My server is Ubuntu 18, with apache 2 and PHP 7.2, and Thirtybees 1.0.3 I have recently moved to a new host but don't recall seeing these errors on my old server which was Centos 7, Apache 2 and PHP 7.0

Share this post


Link to post
Share on other sites

7 answers to this question

Recommended Posts

  • 0

I think it is becaus of PHP 7.2 you should use only to PHP 7.1 (not over), this should fix the warnings.

Some warnings of PHP are without any further problems, but maybe it is better to use only 7.1

Share this post


Link to post
Share on other sites
  • 0

Ubuntu 18.04 installs PHP 7.2 as the default version so I would have to downgrade to use 7.1, For now it is only warning messages I will check if there are any actual errors before downgrading as that would involve further downtime on my site.

Share this post


Link to post
Share on other sites
  • 0

Downgrading PHP won't really solve the problem, it just hides it. The underlying problem is this:

http://php.net/manual/en/migration72.incompatible.php#migration72.incompatible.warn-on-non-countable-types

I just looked into the code, but found nothing related at the given line numbers. Maybe the line numbers don't match. Could you post a couple of lines of context, please? Code at the given line number, plus some 10 lines around it. This should help to locate the code at fault. Thanks.

Share this post


Link to post
Share on other sites
  • 0

I also faced with this thing: On php 7.2 if(count($errors)) gives this warning, while if(!empty($errors)) not

Another issue: each() function is deprecated in 7.2, while it has been used in smarty supplied with 30BZ bundle. Even more annoying is that some modules of 3-party theme (transformer) won't work properly with rerwritten URLs on php7.2. So downgrade now is inevitable thing for ordinary TB user/merchant

Share this post


Link to post
Share on other sites
  • 0

On php 7.2 if(count($errors)) gives this warning, while if(!empty($errors)) not

It depends on what should be counted. Arrays can be counted, integers/strings/booleans not. Accordingly we have to find out what kind of variable is subject to counting.

A quick Grep brings up 882 usages of count(), too many to do a code analysis on each. That's why I'd be happy about code pointers.

Share this post


Link to post
Share on other sites
  • 0

The most uncertain for me is that currently used version of smarty also has a number of functions are deprecated in php 7.2... So, what to do with this?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...