If one user adds a product node to his cart, and an admin deletes said node, the checkout page will throw an error trying to clone a non existing node instead of removing deleted node from cart.

Comments

longwave’s picture

Presuming this is the same as #1443316: Fatal error: __clone method called on non-object in uc_product\uc_product.module on line 638 - you didn't specify the exact error message - can you test the patch there and report back?

ramez.gaberiel’s picture

Apologies, yes this is the same error I get:
__clone method called on non-object in .../uc_product.module on line 654
I had added some custom code before to try and bypass that error so it appears on a different line but it is essentially the same error.
I applied your patch and at least the page loads with warnings instead of just dieing with an error.
If you would like to reproduce the error: (before applying your patch)
go to store -> click on Manage classes -> fill out the fields to add a class and save.
That will create a new content type with that class you just created, now go add content of that product class type you just created and add it to you cart.
(I did all of this logged in as superadmin)

Now go back to the store and manage classes, from there delete the class you just created. When you delete the class (essentially the content type) it does not erase the product nodes that where associated with that class it just leaves them under content and in your shopping cart as well.
Now go delete the node itself that you created (that is now without a type) and go view your shopping cart and you will see said white screen of death because it is trying to clone a node that it thinks is there but was actually deleted.

A simple fix would be once the instruction to delete the class (or content type) of that product is received, go through each item in the shopping carts first and remove all items of that class, and then delete the class.

I will try creating a patch with the logic I just mentioned if I have time over the weekend as I get more familiar with ubercart but I appreciate your response and effort.

Just to let you know new warnings arose with your patch:

Notice: Undefined property: stdClass::$price in uc_product_uc_cart_display() (line 1043 of ... /uc_product/uc_product.module).

Thanks again

longwave’s picture