Jump to content
thirty bees forum

Panda and other fixes


musicmaster

Recommended Posts

The Panda theme produces quite a lot of warnings for the error log. Usually they are harmless. In this post I will list the warnings and the fixes. As the Panda theme hasn't been upgraded for some time this will enable you to do it yourself.

Make sure to update your modules and Thirty Bees to the last version. Make also sure that you have the latest version of Panda: older versions are quite different and with them the line numbers won't match.

I haven't enabled all modules and tested them in all corners. So there may still be hidden problems. If you encounter a problem and find a solution, please report it here so that I can add it to the list. If you aren't able to solve it I will be happy to help you.

SunnyToo has promised that they will release a new version.

 

blockcart-json.tpl

Warning:  Creating default object from empty value in
/home/public/sites/www.shop.com/cache/smarty/compile/11/2b/10.file.blockcart-json.tpl.php on line 218 

/themes/panda/modules/blockcart-json.tpl

The offending line is line 81. It looks so:

"free_ship": {(!$shipping_cost_float && !count($cart->getDeliveryAddressesWithoutCarriers(true, $errors_back)))|json_encode},

To fix it it should be changed to by deleting the $errors_back argument

"free_ship": {(!$shipping_cost_float && !count($cart->getDeliveryAddressesWithoutCarriers(true)))|json_encode},

If you have another template that overrides the blockcart template you are likely to encounter the same issue. A very similar fix was made to the blockcart module. That fix provides also three other fixes that should be implemented. These are in the more remote parts of the code so you won't see the errors often:

/themes/panda/modules/blockcart/includes/dropdown.tpl line 113

change:   {assign var='free_ship' value=count($cart->getDeliveryAddressesWithoutCarriers(true, $errors))}

to:     {assign var='free_ship' value=count($cart->getDeliveryAddressesWithoutCarriers(true))}

/themes/panda/order-carrier-advanced.tpl  line 264 and 

/themes/panda/order-carrier-opc-advanced.tpl  line 250

change: {assign var='errors' value=' '|explode:''}

to: {assign var='errors' value=[]}

 

blockviewed

There is a fix for the TB version of this module that you can also apply to your blockviewed_mod. It is discussed here and you can find the code here. As it concerns quite a lot of code I haven't copied it here. 

Note that this concerns a possible problem and it doesn't produce error messages - except for the browser console when the rare problem really happens.

 

blockwishlist

[] PHP Warning:  count(): Parameter must be an array or an object that implements Countable in
/home/public/sites/www.webshop.com/cache/smarty/compile/ba/cb/c4/bacbc7.file.blockwishlist-extra.tpl.php on line 25

/themes/panda/modules/blockwishlist/blockwishlist-extra.tpl

Line 28 looks like this:

{if isset($wishlists) && count($wishlists) > 1}

This should be changed to 

{if isset($wishlists) && is_array($wishlists) && count($wishlists) > 1}

 

breadcrumb.tpl

[] PHP Warning:  Creating default object from empty value in 
/home/public/sites/www.webshop.com/cache/smarty/compile/fe/8c/6b/fe1_0.file.breadcrumb.tpl.php on line 32

The offending line is:

{$matchCount = preg_match_all('/<a.+?href="(.+?)"[^>]*>([^<]*)<\/a>/', $path, $matches)}

The problem is that $matches is not defined. So you need to add a line before this line:

{$matches = []} 

 

guest.php

[] PHP Notice:  Trying to access array offset on value of type bool in 
/home/public/sites/www.webshop.com/classes/Guest.php on line 207

This error can happen in older shops. It happens because some entries are lacking in the ps_operating_systems entries for more recent OS's are missing. If you scroll a bit up from line 207 you will see which OS's are defined in the software.

 

paypal.php and stnewsletter

Array and string offset access syntax with curly braces is no longer supported
in file /home/public/www.website.com/modules/paypal/paypal.php at line 2729

This type of error is quite common and happens also with other modules.

It has to with the syntax for arrays. Normally you write something like "$myarray[8]". However, there is an old type of syntax that uses curly brackets instead of the square brackets. In that case the same declaration looks like "$myarray{8}". In PHP 8 the latter syntax is no longer allowed. So you need to replace the curly brackets with square brackets.

So

if ((int) $num1{$i} > (int) $num2{$i})

will be replaced by

if ((int) $num1[$i] > (int) $num2[$i])

stnewsletter has a similar problem on line 122.

 

stgadwordsconversion.php

[] PHP Warning:  Undefined array key "total" in
/home/public/sites/www.webshop.com/cache/smarty/compile/53/63/eb/5363eb.file.front.tpl.php on line 32
[] PHP Warning:  Undefined array key "iso_code" in
/home/public/sites/www.webshop.com/cache/smarty/compile/53/63/eb/5363e.file.front.tpl.php on line 34
[] PHP Warning:  Undefined array key "total" in 
/home/public/sites/www.webshop.com/cache/smarty/compile/53/63/eb/5363.file.front.tpl.php on line 32
[] PHP Warning:  Undefined array key "iso_code" in 
/home/public/sites/www..webshop.com/cache/smarty/compile/53/63/eb/5363.file.front.tpl.php on line 34

/modules/stgadwordsconversion/stgadwordsconversion.php

This error always comes in fourfold when an order is made. Two times before the payment is made and two times in the callback from the payment provider.

This is a module that used to be provided by SunnyToo. However, it is no longer supported and for me that was a reason to stop using it.

 

stmegamenu.php

[] PHP Warning:  "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? 
in /home/public/sites/www.webshop.com/modules/stmegamenu/stmegamenu.php on line 3724
[] PHP Warning:  "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? 
in /home/public/sites/www.webshop.com/modules/stmegamenu/stmegamenu.php on line 3739

/modules/stmegamenu/stmegamenu.php

As "continue" is the old version and it works so I have replaced "continue" here with "break".

 

stnewsletter

Error message in the browser console from php-debug.js

Deprecation: Array and string offset access syntax with curly braces is deprecated 
in modules/stnewsletter/stnewsletter.php at line 123 php-debug.js:53:39

Change in /modules/stnewsletter/stnewsletter.php on line 123

if ($this->_cookie_path{0} != '/')

into 

if ($this->_cookie_path[0] != '/')

 

stthemeeditor

Symptom: when in the backoffice you want to configure this module it your modules page the call keeps hanging until you get some kind of timeout (for example a 504 error). When you look in the browser console under Network you see that the status of the call is "pending". When you look under Timing you see "call is not finished yet".

This happens when some SunnyToo webpage is down. Just waiting will solve the problem. But if you want to access your theme-editor immediately here is a fix.

The problem is in the function getVerInfo in the file /modules/stthemeeditor/ThemeLicense.php

	public function getVerInfo()
	{
		if (!isset($_SESSION['st_version_info']) || !$_SESSION['st_version_info']) {
			$api_url = 'http://biz236.inmotionhosting.com/~sunnyt7/version.php';
			$theme = $this->getTheme();
			$param = array(
				'theme' => $theme,
				'ver_only' => false,
			);
			if ($data = $this->makeCall($param, $api_url)) {
				$_SESSION['st_version_info'] = $data;
			} else {
				$_SESSION['st_version_info'] = '';
			}
		}
		return $_SESSION['st_version_info'];
	}

The link to inmotionhosting no longer works. Unfortunately that makes the function makeCall hang rather than return false.

So a solution is to replace 

			if ($data = $this->makeCall($param, $api_url)) {
				$_SESSION['st_version_info'] = $data;
			} else {
				$_SESSION['st_version_info'] = '';
			}

with just the line

$_SESSION['st_version_info'] = '';

Possibly this is a temporary problem and SunnyToo will fix it.

 

The themeconfigurator module

After I had upgraded PHP to version 8.1 I found that I couldn't access my backoffice. It had an error in the themeconfigurator module. 

This module was not active. Yet it was somewhere accessed by the theme. 

The problem here is that Thirty Bees doesn't upgrade modules that are not active. So in this shop - a migrated Prestashop - I still had the old Prestashop version. 

The solution was to delete this old version and copy a new version of this module from a recent Thirty Bees installation.

Here an update file that fixes some of the issues.

 

yotpo.php

The Yotpo module produced the following warning:

Warning:  count(): Parameter must be an array or an object that implements Countable in
/home/public/sites/www.webshop.com/modules/yotpo/yotpo.php on line 268

The relevant code was:

$id_image = Product::getCover($id_product);
if (count($id_image) > 0)

Obviously this was a programming error on the side of Yotpo. $id_image is just a variable, not an array. So the corrected code became:

$id_image = Product::getCover($id_product);
if ($id_image > 0)

 

The backoffice Modules page

Under PHP 8.1 you will see in the backoffice Modules page warnings like the following:

Deprecated: Optional parameter $type declared before required parameter $id_lang is implicitly treated
as a required parameter in StMultiLinkGroup.php on line 127

The offending code in this case is:

public static function getLinkGroup($identify,$type=1,$id_lang)

You can solve this by stripping "=1" from the "$type=1" part. The same applies to other function declarations with the same problem.

 

Optional parameter $nbr declared before required parameter

You will see a lot of these warnings when you open the Modules page in the backoffice. 

Guilty are function declarations like this

public static function getByCustomer($id_customer, $p = 1, $n = 0, $id_lang, $id_shop, $get_total = false)

The problem are those definitions like "$p = 1". You can leave the values out.

So the above function would become:

public static function getByCustomer($id_customer, $p, $n, $id_lang, $id_shop, $get_total = false)

As these are harmless I haven't changed them myself.

Edited by musicmaster
  • Like 5
Link to comment
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...