the issue is related to session storage

  • Posts: 19
  • Thank you received: 1
  • Hikamarket Multivendor Hikashop Business
23 hours 43 minutes ago #370506

-- HikaShop version -- : 6.3.0
-- Joomla version -- : 5.4.3
-- PHP version -- : 8.3
-- Browser(s) name and version -- : Version 145.0.3800.58 (Official build) (64-bit)
-- Error-message(debug-mod must be tuned on) -- : Exception
Exception:
Serialization of 'SimpleXMLElement' is not allowed

  at /home/shepherdsstream/public_html/libraries/src/Session/Storage/JoomlaStorage.php:146
  at serialize()
     (/home/shepherdsstream/public_html/libraries/src/Session/Storage/JoomlaStorage.php:146)
  at Joomla\CMS\Session\Storage\JoomlaStorage->close()
     (/home/shepherdsstream/public_html/libraries/vendor/joomla/session/src/Session.php:557)
  at Joomla\Session\Session->close()
     (/home/shepherdsstream/public_html/plugins/system/debug/src/Extension/Debug.php:319)
  at Joomla\Plugin\System\Debug\Extension\Debug->onAfterRespond()
     (/home/shepherdsstream/public_html/libraries/vendor/joomla/event/src/Dispatcher.php:454)
  at Joomla\Event\Dispatcher->dispatch()
     (/home/shepherdsstream/public_html/libraries/vendor/joomla/application/src/AbstractApplication.php:99)
  at Joomla\Application\AbstractApplication->dispatchEvent()
     (/home/shepherdsstream/public_html/libraries/src/Application/CMSApplication.php:347)
  at Joomla\CMS\Application\CMSApplication->execute()
     (/home/shepherdsstream/public_html/includes/app.php:58)
  at require_once('/home/shepherdsstream/public_html/includes/app.php')
     (/home/shepherdsstream/public_html/index.php:51)      

After enabling the Debug system, I reviewed the error log and found that the issue is related to session storage. It appears that this error may be caused by the new feature in the latest version of HikaShop that stores cart items in the session. I also tried removing the HikaShop override files from the template, but this did not resolve the issue. Can you please review and fix this problem in the core files of the component? As a temporary measure, I have disabled the Cart module published in the menu position to prevent the error from affecting other pages.

Last edit: 23 hours 39 minutes ago by ShepherdsStream.

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

  • Posts: 85115
  • Thank you received: 13884
  • MODERATOR
18 hours 54 minutes ago #370508

Hi,

HikaShop doesn't store the cart in the user session. It never did and it still doesn't in the latest version.
How did you find that this error would be caused by this ?
From the debug data you provided it's hard to say anything. It could come from any extension on your website.
The fact that no one else had the issue after 2 weeks HikaShop 6.3.0 has been released would indicate that the problem is not in the core of HikaShop.
The fact that not publishing the cart module on the pages make the pages work seems to point at something linked to HikaShop but it's hard to say more.
We'll need more debug to understand the problem.
Edit the file libraries/src/Session/Storage/JoomlaStorage.php via FTP.
There, replace the code

    public function close(): void
    {
        // Before storing data to the session, we serialize and encode the Registry
        $_SESSION['joomla'] = base64_encode(serialize($this->data));

        parent::close();
    }
by:
  public function close(): void
  {
      try {
          $_SESSION['joomla'] = base64_encode(serialize($this->data));
      } catch (\Throwable $e) {
          $dataArray = (array) $this->data->toObject();
          $results = [];
          $this->findUnserializable($dataArray, '', $results);
          file_put_contents(
              JPATH_ROOT . '/tmp/session_debug.log',
              date('Y-m-d H:i:s') . ' - ' . $e->getMessage() . "\n" .
              implode("\n", $results) . "\n\n",
              FILE_APPEND
          );
          $_SESSION['joomla'] = '';
      }

      parent::close();
  }

  private function findUnserializable($data, $path, &$results)
  {
      if ($data instanceof \SimpleXMLElement) {
          $results[] = $path . ' => SimpleXMLElement: ' . $data->asXML();
          return;
      }
      if (is_object($data)) {
          try { serialize($data); return; } catch (\Throwable $e) {}
          foreach (get_object_vars($data) as $k => $v) {
              $this->findUnserializable($v, $path . '->' . $k, $results);
          }
      } elseif (is_array($data)) {
          foreach ($data as $k => $v) {
              $this->findUnserializable($v, $path . '[' . $k . ']', $results);
          }
      }
  }
Then, display a page with the issue and check the file tmp/session_debug.log
It should provide helpful information on what's going on.
Please share the content of that file. You can then revert the change in libraries/src/Session/Storage/JoomlaStorage.php

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

  • Posts: 19
  • Thank you received: 1
  • Hikamarket Multivendor Hikashop Business
5 hours 33 minutes ago #370522

Greetings, you were correct. It was from a custom tax plugin we wrote. Thank you for your help. :oops:

The following user(s) said Thank You: nicolas

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

Time to create page: 0.062 seconds
Powered by Kunena Forum