Post by sanshay » Sat May 12, 2018 12:38 am

Hello
I have updated my server from php 5.6 to 7.2
Now i get error

Code: Select all

PHP Warning:  count(): Parameter must be an array or an object that implements Countable in /xxxxx/xxxxx/xxxxx/xxxxx/public_html/catalog/model/tool/path_manager.php on line 49
When i view the code:

Code: Select all

if (count($banned_cats) && (count($categories) > 1)) {
        if (in_array($path[$key], $banned_cats)) {
						unset($path[$key]);
				} else if (preg_match('#[_=](\d+)$#', $path[$key], $cat)) {
					if (in_array($cat[1], $banned_cats)) {
						unset($path[$key]);
          }
I have the same error on my 3 stores
Any one have Idea

Regards

Active Member

Posts

Joined
Fri Jan 25, 2013 8:49 pm

Post by Johnathan » Sat May 12, 2018 1:21 am

I don't believe /catalog/model/tool/path_manager.php is a built-in OpenCart file, so this is probably due to a mod you've installed. Try finding the developer of it (perhaps by opening up the file) and contact them to help get it fixed.

Image
Image Image Image Image


User avatar
Global Moderator

Posts

Joined
Fri Dec 18, 2009 3:08 am


Post by IP_CAM » Sat May 12, 2018 7:59 am

Well, this PHP 7.2.x related Problem seems to be very common in many
software installations, not only in Opencart, as I found out. So, I switched
back to PHP 7.1.xx again, and it was gone. Just to mention it.
Ernie
https://wiki.php.net/rfc/counting_non_countables

Please don't send me OC Forum Personal Messages, just contact: jti@jacob.ch
---
OC 1.5.6.5 LIGHT Test Site: http://www.bigmax.ch/shop/
OC 1.5.6.5 V-PRO Test Site: http://www.openshop.li/shop/
My Github OC Site: https://github.com/IP-CAM
2'600+ FREE OC Extensions on the World's largest Github OC Repository Archive Site.


User avatar
Legendary Member

Posts

Joined
Tue Mar 04, 2014 1:37 am
Location - Switzerland

Post by sanshay » Sun May 13, 2018 1:40 am

Hello
It was indeed from a module. That has been fixed.
A lot of modules are updated now.
Still a few errors, but finding out where they come from.
Regards

Active Member

Posts

Joined
Fri Jan 25, 2013 8:49 pm

Post by sanshay » Sun May 13, 2018 1:45 am

IP_CAM wrote:
Sat May 12, 2018 7:59 am
Well, this PHP 7.2.x related Problem seems to be very common in many
software installations, not only in Opencart, as I found out. So, I switched
back to PHP 7.1.xx again, and it was gone. Just to mention it.
Ernie
https://wiki.php.net/rfc/counting_non_countables
Indeed, i have updated all my clients website, like wordpress,, other cms software.
Now updating one by one the opencart stores ( 4 running on 2.3.0.2) 1 is in building mode 3.0.2 where i het a lot off errors but was on php 5.6
So i hope its gone with the new php 7.2.5

Keep this post updated ;-)

Active Member

Posts

Joined
Fri Jan 25, 2013 8:49 pm

Post by sanshay » Tue May 15, 2018 8:25 pm

More info founded:
Here you can see where you should take into account the upgrade to PHP 7.2: https://secure.php.net/manual/en/migration72.php

Specifically this section seems to refer to the count function:
https://secure.php.net/manual/en/migrat ... atible.php (part "Warn when counting non-countable types")

That indicates that a count is executed on a type that would always have the same value because there is nothing to count within that data type.
This will give the same result in previous PHP versions only now there is a warning given that here is an expected error in the code.

Active Member

Posts

Joined
Fri Jan 25, 2013 8:49 pm

Post by RideTheWave » Sat Mar 21, 2020 12:00 pm

Sanshay, can you tell us what exactly did you change in your code to make it work?

New member

Posts

Joined
Fri May 19, 2017 8:29 am

Post by letxobnav » Sat Mar 21, 2020 1:37 pm

The smart way is to not use count on variables which are not countable.
The dumb way is to check if the variable is countable by using is_countable() before the count.

Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces

“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.


User avatar
Expert Member

Posts

Joined
Fri Aug 18, 2017 4:35 pm
Location - Taiwan

Post by IP_CAM » Sat Mar 21, 2020 9:27 pm

Just to have it mentioned, it's the ZIP File enclosed, containing that path_manager.php File.
Ernie

Please don't send me OC Forum Personal Messages, just contact: jti@jacob.ch
---
OC 1.5.6.5 LIGHT Test Site: http://www.bigmax.ch/shop/
OC 1.5.6.5 V-PRO Test Site: http://www.openshop.li/shop/
My Github OC Site: https://github.com/IP-CAM
2'600+ FREE OC Extensions on the World's largest Github OC Repository Archive Site.


User avatar
Legendary Member

Posts

Joined
Tue Mar 04, 2014 1:37 am
Location - Switzerland

Post by triaumceo@gmail.com » Wed Apr 01, 2020 2:37 pm

Please help to fix this problem

Code: Select all

Warning: count(): Parameter must be an array or an object that implements Countable in /home/XXXXXXX/domains/XXXXXXX/public_html/catalog/controller/extension/module/so_latest_blog.php on line 190
OPENCART Version 3.0.0.2
PHP 7.2

Code: Select all

$blogs =  array();
190  	if(count($str_categorys) && $str_categorys != "")
		{
			$filter_data = array(
				'category_id'	=> $str_categorys,
				'sort'  		=> $setting['sort'],
				'order' 		=> $setting['order'],
				'start' 		=> 0,
				'limit' 		=> $setting['limit']
			);
			$blogs = $this->model_extension_module_so_latest_blog->getListBlogs($filter_data);
			
			$users = $this->model_extension_module_so_latest_blog->getUsers();
			
Last edited by straightlight on Wed Apr 01, 2020 6:26 pm, edited 1 time in total.
Reason: Removed constant caps and added code tags.


Posts

Joined
Thu Mar 26, 2020 6:53 pm

Post by Johnathan » Wed Apr 01, 2020 10:47 pm

That code is for a commercial extension, so you should probably contact its author to get assistance. Based on the code you posted, this edit may work, but only the developer knows exactly how that variable is set:

Code: Select all

REPLACE:
if(count($str_categorys) && $str_categorys != "")

WITH:
if (!empty($str_categorys))

Image
Image Image Image Image


User avatar
Global Moderator

Posts

Joined
Fri Dec 18, 2009 3:08 am

Who is online

Users browsing this forum: No registered users and 10 guests