Skip to content
View in the app

A better way to browse. Learn more.

thirty bees forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

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

Featured Replies

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

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

  • Author

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.

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.

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

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.

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?

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.