First of all, I hope I'm not duplicating the issue, but I haven't found anything on this case yet.
Few days ago I have moved little site with Drupal Commerce on it. It appears that adding a product to cart throws notice error:

Notice: Only variables should be passed by reference w commerce_cart_product_add() (line 1342 from /var/www/d7/sites/all/modules/commerce/modules/cart/commerce_cart.module).

It is regular Add to cart button from Product Reference field in node, so no hacks or magic to ruin the code.
But since this site was moved to PHP7 server, I knew it has probably something to do with this fact.
Solution for this is easy - replacing clone($line_item) usage with variable with cloned object. I'm attaching small patch to fix this.

Comments

tomrog created an issue. See original summary.

smccabe’s picture

Status: Active » Needs review

Looks good, confirmed same fix works locally. Setting to needs review to trigger testbot

smccabe’s picture

StatusFileSize
new718 bytes

Oh, patch wasn't in comment, won't trigger, uploading just to trigger, no changes.

Status: Needs review » Needs work

The last submitted patch, 3: cart_product_add_php7_fix1.patch, failed testing.

smccabe’s picture

Status: Needs work » Needs review
StatusFileSize
new682 bytes

Patch was not made relative and didn't apply, rerolled with proper paths

fbailey’s picture

Status: Needs review » Reviewed & tested by the community
smccabe’s picture

The 2 fails in PHP7 are from ctools and are fixed in the dev release of ctools

tomrog’s picture

Thanks for quick testing ;)

rszrama’s picture

Status: Reviewed & tested by the community » Fixed

Thanks guys! Committed.

  • rszrama committed f72e268 on 7.x-1.x authored by tomrog
    Issue #2762907 by tomrog, smccabe: fix a pass-by-reference error in...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

howdytom’s picture

Patch #5 works for me.

Excellent. Thank you, smccabe

kevin morse’s picture

Any idea when this will be released?

wizonesolutions’s picture

EDIT: nevermind, I got my dates mixed up.

Yeah, this doesn't even seem to have appeared in the dev release? Strange.

gthing’s picture

This is not fixed. I just did a clean install and ran into this error when trying to enable the cart module. I had to implement the fix myself.

rodrigoaguilera’s picture

There is no stable version with this fix. You will have to use a dev version until 1.14 is released

Kiendeleo’s picture

Version: 7.x-1.11 » 7.x-1.13

This fix has still not been added to the current stable release.

crawley’s picture

Thank you. The patch worked for me.

harefine’s picture

Sorry, i ve the same problem - how can i add this patch?

Frank Panduh’s picture

At Line # 1344 changed it to:

$tmp_line_item = clone($line_item);
drupal_alter('commerce_cart_product_comparison_properties', $comparison_properties, $tmp_line_item);

that seemed to make the error go away.

as seen here:

Notice: Only variables should be passed by reference in commerce_cart_product_add()

fonant’s picture

Patch works for me, is simple, and makes sense.

matas.k’s picture

9 months still not in stable release...

agenciaq1’s picture

Hi,

The patch works for me.

Thank you,

jjmackow’s picture

confirmed; altering line 1344 to

$tmp_line_item = clone($line_item);
drupal_alter('commerce_cart_product_comparison_properties', $comparison_properties, $tmp_line_item);

***
issue began to occur only after upgrading from PHP 7.0 to the latest PHP 7.1 and then having run cron on the drupal instance, commerce cart module had been running OK with PHP 7.0 ;
making the changes allowed me to run commerce cart with PHP 7.1

thomas.claes’s picture

I can confirm patch #5 is working. (tested on PHP 7.1.2)
Can a new 7.x-1.x version be created, please?

redeight’s picture

Patch #5 worked for me as well. Any word on when we'll get a stable release?

Bram Esposito’s picture

patch #5 worked. A release would be appreciated.

gangwarsurya’s picture

Thanks smccabe

Patch #5 Worked. I had applied this patch and work for me.

alislis’s picture

Tested on PHP 7.1, D7 + Commerce.
Was an error on commerce_cart, and patch#5 worked for me, thanx.

erier’s picture

Patch #5 also worked for me. Whats taking so long on the stable release?

ddhuri’s picture

Thanks smccabe

Patch #5 Works for me.

nachus’s picture

Same error here, the patch works for me. Thanks!

kevster’s picture

Many thx - #5 helped fix my problem - error gone now!

forwardslashuser’s picture

#5 worked for me. Thank you.

dunebl’s picture

#5 solve my problem too

drupal-son’s picture

Hi @rszrama,

I'm upgrading a website to PHP7.x (Drupal 7.59 and PHP 7.1) and updating commerce module from 7.x-1.13 to 7.x-1.14.

After updating the module, I've got a "FacesExtendableException: There is no method getElementName for this instance of the class RulesConditional. in /app/sites/all/modules/rules/includes/faces.inc:133" error and can't access rules and payment methods any more (WSOD).
Or when trying to clear caches.
Same happens using the latest 7.x-1.x-dev version.

If I rollback to version 7.x-1.13 and apply the patch #5 it works, but not on version 1.14 where the patch should be committed to.

Is it safe to stay in commerce 7.x-1.13 running PHP 7.1?
Any idea why the 7.x-1.14 version is not working?

Thanks.

kris77’s picture

Patch #5 Works for me too.

Thanks @smccabe

jasonschweb’s picture

This patch appears to have included in commerce 1.15 but not included on the release notes.

howdytom’s picture

@ jasonschweb: Yes, Patch#5 has already been included in commerce 7.x-1.15. It's missing in the release notes.

suparnaa.dey’s picture

#5 works for me

suparnaa.dey’s picture

#5 works for me