[SOLVED]VM2.0.4 Cart Module Error: Warning: unserialize() [function.unserialize]

Started by ejd, April 12, 2012, 12:25:34 PM

Previous topic - Next topic

ejd

Joomla 2.5.4
PHP 5.3.8
SEF programs turned off.

Did a clean install of VM 2.0.4 and AIO 2.0.4
Note:  There seems to be a version number problem with the AIO package. I downloaded and installed 2.0.4 but it says it is v2.0.3:
Installed version 2.0.3
Latest version 2.0.4

The Shopping Cart module works fine ONLY if it is on the same page as the VM Store page.
If it is used on ANY other page as well, then the module has this error in it:

Warning: unserialize() [function.unserialize]: Function spl_autoload_call() hasn't defined the class it was called for in /home/stacecos/public_html/components/com_virtuemart/helpers/cart.php on line 91

Try this: ADD an item to the cart.

The cart is working here:
http://www.stacecosmetics.com/buy-online-now

The cart is broken on every other page:
http://www.stacecosmetics.com/be-part-of-the-magic

If there are two items in the cart then the error will be shown TWICE, etc.

ejd

SOLVED (sort of):

If I turn the ERROR REPORTING to OFF then those errors don't show visibly on the front end.
OK, it is a solution.
Doesn't fix why it is happening though.

edcv

VM 2.08c here
I get this same error.

But only when I'm on the frontpage of my site. Virtuemart is not the frontpage, maybe something related to that?


Russell Walker

Suppressing the error does not solve the problem, it just hides it. There are a few other topics on here about the same issue but nobody seems to have provided a resolution. I did some investigation and for me, most of the classes in the serialized string were 'stdClass' (which is part of the PHP core and always exists), but there was one reference to the class 'vmImage' which might not always be loaded by the time the shopping cart is shown (in particular, if the cart is shown on a non-VM page). So I added a line to load the file that contains that class, and that seemed to fix it for me. 

In the file /components/com_virtuemart/helpers/cart.php, around line 92 (in version 2.0.14 - might be on a nearby line in other versions) where it says:

if (!empty($cartSession)) {
  $sessionCart = unserialize( $cartSession );


...add a line immediately before the call to unserialize to load the class, so it now says:

if (!empty($cartSession)) {
  include_once(JPATH_VM_ADMINISTRATOR.DS.'helpers'.DS.'image.php');
  $sessionCart = unserialize( $cartSession );


balai

Could you please integrate this also to the core?
Because it seems that this fix is still not included in the core