I am getting this following fatal error once I logged in as sub admin [ Custom user role created by super admin ] . If I logged in as super admin, then this error is not displaying but I am getting this error if i logged in as other user who has permission to access order administration.
Fatal error: __clone method called on non-object in
profiles/commerce_kickstart/modules/contrib/commerce_discount/commerce_discount.module on line 33
I hope the problem is with the following code in commerce_discount.module
Line 33:
$cloned_line_items[$wrapper_line_item->getIdentifier()] = clone($wrapper_line_item->value());
Please see it and let me know it. Thanks in advance.
Comments
Comment #1
gianlucarossi commentedUp? Have the same problem.
Comment #2
ralt commentedHi,
I can't reproduce after trying to create a user with somehow admin access... can you describe a procedure to exactly reproduce?
Thanks,
Comment #3
ralt commentedComment #4
bechtold commentedHey,
I had exactly the same error when trying to access orders.
I can't really reproduce the error at the moment, but I believe ist must have been an anonymous order.
Because I was experimenting with those when the error appeared.
Seems to be a line-item that is empty. This fix I offer allowed me to get rid of the error and access the order page. After saving the order or the payment (I don't remember exactly) the error was gone.
The solution I found is maybe not the best, because I don't know what we miss out, or what this function should be doing.
So maybe the maintainers can say a word where this might come from.
Until they have spoken, I recommend to use the patch only if you are stuck on your orders page and don't find another solution.
Maybe it's a good idea to remove the patch again, as long as the error is not appearing.
Cheers
bechtold
Comment #5
andrewsizz commentedHey Oskar,
I think better will be:
As $line_item variable always will be and in this case isset always will returns TRUE.
Comment #6
rsvelko commentedmy several cents:
- I downloaded 7 dev of this module
- the clone keyword is used only in one place on line 33
- here is some code context:
So, here is my patch attached - which is an adaptation of all other patches and the previous comment suggestion to use ! empty and is_object.
I am still not sure if we should check for isset or empty ? Maybe add isset check in front of the rest ?
Comment #7
rsvelko commentedComment #8
korlandi commentedI have this same error when accessing the Manage Orders page. For me, it happened when I uploaded a new inventory list. For the past three months the 30+ inventory lists I uploaded did not trigger this error, but this time it did. I scrubbed the file for data issues, but could not identify any. The inventory file only contained changes to price and quantity and active status, nothing about discounts.
Fatal error: __clone method called on non-object in .../profiles/commerce_kickstart/modules/contrib/commerce_discount/commerce_discount.module on line 33
It goes away if I disable the discount module altogether, which isn't ideal. The Coupon module seems to still work, so our commerce site is getting by using just that, but I really would like the extremely helpful Discount Module functionality.
Following this post to see if/when a solution is found. Thanks!
Comment #9
jmary commentedPatch #6 seems to have solved the issue.
Comment #10
joelpittetThank you @rsvelko This looks good, just a couple of nitpicks on #6:
Which could be fixed on commit.
Spaces around the ! aren't part of the coding standards.
clone is a language construct not a function, doesn't need the parenthesis.
http://php.net/clone
Comment #11
deggertsen commentedWhat's the difference between this issue and #2107617: Cloning discount offers is broken?
Comment #12
joelpittet@deggertsen one is cloning the discount entity in the UI, and this one is an error in trying to clone a line item on order refresh.
Comment #13
joelpittetThe
empty()check should actually do anything because it's an object and not an array or scalar value.Here's why:
http://3v4l.org/FR7S2
How about this?
Comment #14
joelpittet@deggertsen or @rsvelko if you are cool with that rational? I'll commit this patch.
Comment #15
deggertsen commentedSounds good to me!
Comment #16
joelpittetCool committed, thanks @deggertsen