During checkout: Object of class stdClass could not be converted to string

  • Posts: 220
  • Thank you received: 8
2 years 8 months ago #340028

-- HikaShop version -- : 4.3.0
-- Joomla version -- : 3.10.6
-- PHP version -- : 7.4.28
-- Error-message(debug-mod must be tuned on) -- : Object of class stdClass could not be converted to string

Hi,

Suddenly checkout in the shop is blocked.

No problem in the first checkout step, the login.
In the second step the customer selects addresses. Clicking the button Next step results in a white page, 500 Internal Server Error, showing the text

Object of class stdClass could not be converted to string

This is in PHP 7.4.
When downgrading to PHP 7.3 the white page already comes right after the first step.
Then the error text is
Recoverable fatal error:  Object of class stdClass could not be converted to string in /PRIVATE/public_html/libraries/joomla/database/driver/mysqli.php on line 254

Just before I upgraded Joomla 3.9.28 to Joomla 3.10.6
So that's probably related to the problem.

Please advice how to solve this problem.

Udo

EXTRA INFORMATION !
In error_log I discovered older notifications that might give a clue:
At that time I was still using Joomla 3.9.28 en PHP 7.3
PHP Warning:  mysqli_real_escape_string() expects parameter 2 to be string, object given in /PRIVATE/public_html/libraries/joomla/database/driver/mysqli.php on line 254

Last edit: 2 years 8 months ago by Udo.

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
2 years 8 months ago #340029

Hi,

It's hard to say because that error is in a Joomla file and the error message you provided doesn't contain the callstack which would display which file used the mysqli.php file.
Could you activate the "debug system" option of the Joomla configuration ? That should hopefully give more information when you reproduce the problem.
If not then I don't know. It's possible that the error is not even in HikaShop but in something else used on the page (a 3rd party extension, a custom plugin, etc). So even updating HikaShop might not help.

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

  • Posts: 220
  • Thank you received: 8
2 years 8 months ago #340044

Hi,

I just discovered on my local test website that there is no problem in Joomla 3.10.5
When upgrading 3.10.5 to 3.10.6 the problem arises.
So the issue is Joomla 3.10.6 related.

Udo

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
2 years 8 months ago #340053

Hi,

I tried a checkout on my end on a local test environment with Joomla 3.10.6 but I didn't get the error either.

From what I understand, the error happens on line:

$result = mysqli_real_escape_string($this->getConnection(), (string) $text);
in the file /libraries/joomla/database/driver/mysqli.php because $text isn't a string but an object.

So what you can do to change that code to:
if(is_object($text)) {
echo '<pre>';
var_dump(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS));
echo '</pre>';
exit;
}
$result = mysqli_real_escape_string($this->getConnection(), (string) $text);
That should display the callstack leading to that error so that we better understand where the problem comes from.
And to circumvent the problem, you can try to use:
if(is_object($text)) {
$text = '';
}
$result = mysqli_real_escape_string($this->getConnection(), (string) $text);
that way, you should not get an error but this might lead to unexpected issues on your website... The best would be to figure out the source of the problem.

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

  • Posts: 220
  • Thank you received: 8
2 years 8 months ago #340063

Hi,
Thanks for your information, that comes in handy with new notifications.

Just before I read your reply I tested if upgrading Hikashop might help, although it seems to be a Joomla issue.
And it did help!

After upgrading to Hikashop 4.5.0 the issue is gone, the checkout is okay again and customers can order.

So an Hikashop issue after all?

By the way, I didnot receive any notifications of reply to this topic.

Regards,
Udo

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
2 years 8 months ago #340066

Hi,

Well, with an old version of HikaShop, you risk having issues with recent versions of Joomla and PHP.
It doesn't mean there was a bug in HikaShop 4.3.0. It's just that something HikaShop relied on in Joomla or PHP changed. The modifications we make in HikaShop in every release are also meant to properly support these changes since we can't support them before we know about them.

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

Time to create page: 0.064 seconds
Powered by Kunena Forum