Hello,

Fatal error: __clone method called on non-object in /var/www/username/data/www/site.com/sites/all/modules/commerce/modules/cart/commerce_cart.module on line 791

How to fix?

CommentFileSizeAuthor
#7 $order_wrapper->commerce_line_items.txt35.32 KBAnonymous (not verified)
#7 $order_wrapper.txt24.3 KBAnonymous (not verified)

Comments

amateescu’s picture

Assigned: yu3ver » Unassigned
Status: Active » Postponed (maintainer needs more info)

Can you provide more info about this error? It doesn't sound to be Commerce related. When did it appear, after installing or updating another module?

deggertsen’s picture

I'm getting the exact same error when I try to load the view for the Orders (Commerce Order) -> shopping carts. I have messed with the view quite a bit trying to get it to work and have figured out that it is only when I try to display shopping cart orders that it breaks. So it has something to do with loading orders with the state "shopping cart". Unfortunately don't know much more than that, still try to fix this...

deggertsen’s picture

Status: Postponed (maintainer needs more info) » Active

Marking back to active just in case this info is enough to actually get somewhere. I'm not sure if I can reproduce this problem yet.

Here is a list of modules currently enabled on the site if there is anything there that might be causing the conflict.

ACL 7.x-1.0
Address Field 7.x-1.0-beta2
Administration menu 7.x-3.0-rc1
AmazonS3 7.x-1.0-beta6
AWS SDK for PHP 7.x-5.2
Backup and Migrate 7.x-2.2
CAPTCHA 7.x-1.0-beta2
Chaos tool suite (ctools) 7.x-1.0
Commerce add to cart extras 7.x-1.x-dev (2011-Dec-12)
Commerce Authorize.Net 7.x-1.x-dev (2012-Jan-19)
Commerce AutoSKU 7.x-1.0
Commerce Cart Ajax 7.x-1.0
Commerce Checkout Progress 7.x-1.1
Commerce Coupon 7.x-1.0-beta4+8-dev (2012-Feb-24)
Development version: 7.x-1.x-dev (2012-Apr-20)
Commerce Customizable Products 7.x-1.0-beta1
Commerce Extra 7.x-1.0-alpha1
Commerce extra panes 7.x-1.x-dev (2012-Feb-03)
Commerce File 7.x-1.0-beta3
Commerce Google Analytics 7.x-1.0-rc2
Commerce PayPal 7.x-1.x-dev (2012-Feb-04)
Commerce Product Attributes 7.x-1.0-beta3
Commerce Product Bundle 7.x-1.0-alpha5
Content Access 7.x-1.2-beta1
Date 7.x-2.2
Devel 7.x-1.2
Drupal Commerce 7.x-1.2
Echo 7.x-1.8
Entity API 7.x-1.0-rc1
Entity reference 7.x-1.0-beta5
File entity (fieldable files) 7.x-2.0-unstable3+17-dev (2012-Feb-20)
Development version: 7.x-2.x-dev (2012-Mar-23)
Frequently Asked Questions 7.x-1.0-rc2
Google Analytics 7.x-1.2
HTML Mail 7.x-2.64
Image Resize Filter 7.x-1.13
IMCE 7.x-1.5
IMCE Crop 7.x-1.0
IMCE Mkdir 7.x-1.0
IMCE Wysiwyg bridge 7.x-1.0
Invisimail 7.x-1.1
Job Scheduler 7.x-2.0-alpha2
Libraries API 7.x-2.0-alpha2
Link 7.x-1.0
LoginToboggan 7.x-1.3
Mail MIME 7.x-2.15
Mail System 7.x-2.33
Media 7.x-2.0-unstable3
MediaElement 7.x-1.2
Panels 7.x-3.2
Pathauto 7.x-1.0
Phone 7.x-1.x-dev (2012-Mar-01)
Remote stream wrapper 7.x-1.0-beta3
Rules 7.x-2.1
Simplenews 7.x-1.0-beta2
Simplenews Private Roles 7.x-1.3
Simplenews Statistics 7.x-1.x-dev (2011-Oct-14)
Superfish 7.x-1.8
ThemeKey 7.x-1.5
Token 7.x-1.0-rc1
Views 7.x-3.3
Views Bulk Operations (VBO) 7.x-3.0-rc1
Views data export 7.x-3.0-beta5
Views Slideshow 7.x-3.0
Views Slideshow Xtra 7.x-3.0
Recommended version: 7.x-3.6 (2012-Mar-30)
Views Slideshow: Dynamic Display Block 7.x-2.x-dev (2011-Jul-18)
Webform 7.x-3.17
Weight 7.x-2.0-beta3
Wysiwyg 7.x-2.1
XML sitemap 7.x-2.0-rc1

Themes
Zen 7.x-3.1

OnkelTem’s picture

Having same problem when editing any page - i.e. on any node/%/edit page for any user of Administrator role (which is also setup as administrator) with ALL permissions granted.
But this DOESN'T happen for user/1 user!

wolfwood’s picture

I'm having exactly the same problem. The user/1 is totally uneffected, but the other users with all possible permissions have get the error.

Anonymous’s picture

I'm getting this error as well. I modified the shopping cart block to include a delete button. The error didn't come up until I went down the list and clicked delete on a bunch of cart items without letting the page refresh. These items had accumulated over a long period of site building and testing. I tried to revert the block to the in code version and did not fix the issue.

Anonymous’s picture

StatusFileSize
new24.3 KB
new35.32 KB

Attached is the print_r of my $order_wrapper->commerce_line_items as well as the complete $order_wrapper objects just before the foreach statement on line 790 of the commerce_cart.module.

jonne.freebase’s picture

Having the same issue on admin/commerce/orders/carts . If there's anything you need to get to the bottom of this issue, let me know.

edit: I wrote a workaround where i basically check if $line_item_wrapper->value() is an object before it gets cloned. Just wrap everything in foreach ($order_wrapper->commerce_line_items as $delta => $line_item_wrapper) { in this:

if(is_object($line_item_wrapper->value())){
(...)
}

I have no idea whether this breaks anything else, so use at your own peril!

rszrama’s picture

Priority: Major » Normal
Status: Active » Closed (duplicate)

fwiw, this has since been fixed in core. The code now reads:

    // If the current line item actually no longer exists...
    if (!$line_item_wrapper->value()) {
      // Remove the reference from the order and continue to the next value.
      unset($order_wrapper->commerce_line_items[$delta]);
      continue;
    }

I just don't remember when we actually changed that. : P

gianlucarossi’s picture

Issue summary: View changes

@rszrama I have the same problem, where i have to put the code?

rszrama’s picture

This is a very old issue, its fix long since committed to Commerce. I'm guessing you're experiencing some other issue, possibly as a result of some contributed module.