Error after updating to php 8.1.22

  • Posts: 311
  • Thank you received: 8
  • Hikashop Business
1 year 2 months ago #354856

-- Error-message(debug-mod must be tuned on) -- : Deprecated: strlen(): Passing null to parameter #1 ($string) of type string is deprecated in /home/customer/www/domain.es/public_html/media/com_hikashop/mail/payment_notification.preload.php on line 193

Hi.
A few days ago I updated my site's PHP to version 8.1.22.
Since then I have detected errors in the customer address fields, as well as in the payment confirmation emails.

I attach a screenshot of errors.

Attachments:

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
1 year 2 months ago #354869

Hi,

For the first screenshot, change the line:

if(empty($item->$namekey) && !strlen($item->$namekey)) continue;
to:
if(empty($item->$namekey) && !strlen((string)$item->$namekey)) continue;
in the file media/com_hikashop/mail/payment_notification.preload.php and it will remove these.
We'll add the change on our end for the next version.

Regarding the other screenshot, I don't see the file path in full in your screenshot, so I can't say what to do.
Could you please provide the full path where the deprecated message happens, like you did for the other deprecated message in the email ?

Please Log in or Create an account to join the conversation.

  • Posts: 311
  • Thank you received: 8
  • Hikashop Business
1 year 2 months ago #354879

Hi.
/home/customer/www/domain.es/public_html/administrator/components/com_hikashop/classes/address.php on line 698
(in address - front)

Please Log in or Create an account to join the conversation.

  • Posts: 311
  • Thank you received: 8
  • Hikashop Business
1 year 2 months ago #354882

Another URL with error.
/home/customer/www/domain.es/public_html/administrator/components/com_hikashop/classes/address.php on line 729
/home/customer/www/domain.es/public_html/administrator/components/com_hikashop/classes/address.php on line 698

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
1 year 2 months ago #354897

Hi,

In the file administrator/components/com_hikashop/classes/address.php search for the code:

str_replace('{'.$fieldname.'}',
you'll find it on 3 places. In each place, add
(string)
just after it to get:
str_replace('{'.$fieldname.'}',(string)
and it will remove these deprecated messages.
We'll add the changes on our end too for the next version.

PS: note that these are not errors. They are messages for developers to update their code for future versions of PHP.
Normally, these deprecated messages shouldn't appear on a live website. So that means that you probably want to check with your hosting why these are being displayed and how to not have deprecated messages.

Please Log in or Create an account to join the conversation.

  • Posts: 311
  • Thank you received: 8
  • Hikashop Business
1 year 2 months ago #354901

Solved.
Thanks.

Please Log in or Create an account to join the conversation.

Time to create page: 0.054 seconds
Powered by Kunena Forum