Hey there
At Koumbit it was discovered #2055815: Module not supporting multilanguage sites and searching through your code there is also plenty of uses of LANGUAGE_NONE. This could become problematic on multilanguage sites later on. It was a problem with fixed coupon until a patch was created so I wanted to bring it to your attention also.
Since we have a bunch of lines
classes/commerce_coupon.inc: $entity->commerce_coupon_code[LANGUAGE_NONE][0]['value'] = commerce_coupon_generate_coupon_code();
commerce_coupon.install: $value = array('line_item_id' => $line_item->line_item_id, 'coupon_id' => $line_item->commerce_coupon_reference[LANGUAGE_NONE][0]['value']);
commerce_coupon.install: $line_item->commerce_coupon_reference[LANGUAGE_NONE][0]['coupon_id'] = $value['coupon_id'];
commerce_coupon.install: $value = array('line_item_id' => $line_item->line_item_id, 'coupon_id' => $line_item->commerce_coupon_reference[LANGUAGE_NONE][0]['coupon_id']);
commerce_coupon.install: $line_item->commerce_coupon_reference[LANGUAGE_NONE][0]['target_id'] = $value['coupon_id'];
commerce_coupon.install: $order->commerce_coupon_order_reference[LANGUAGE_NONE][]['target_id'] = $log['coupon_id'];
commerce_coupon.module: $coupon_code = $coupon->commerce_coupon_code[LANGUAGE_NONE][0]['value'];
| Comment | File | Size | Author |
|---|---|---|---|
| #10 | commerce_discount-2055827-10.patch | 1.2 KB | joelpittet |
| #10 | interdiff.txt | 1.11 KB | joelpittet |
| #1 | issue-2055827.patch | 1.11 KB | ralt |
Comments
Comment #1
ralt commentedPatch attached to fix the remaining ones.
Comment #2
joelpittetSeems like a reasonable fix.
Comment #3
bojanz commentedCommitted, thanks.
Comment #5
mattltHello everyone,
I'm getting the following error when running update.php…
Fatal error: Can't use method return value in write context in /home/theperip/public_html_rem/core/core7/sites/all/modules/shop/commerce_discount/modules/commerce_discount_usage/commerce_discount_usage.install on line 156
Reverting this commit lets update.php run as expected. A quick look on the internets says PHP prior to 5.5 may require a different syntax? I'm using 5.4 .
I don't have the knowledge to submit a fix, sorry.
Thanks,
•• matt
Comment #6
bojanz commentedReverted the commit.
Comment #8
joelpittetOh sorry, I should have been more careful on that one, that's a major gotcha with entity_metadata_wrapper()
Comment #9
joelpittetThis uses the magic __isset() method and then grabs the value() as a falsy value. It's what empty() does internally.
> PHP 5.5 has no problem with empty() taking functions.
Comment #10
joelpittetAnd... with the right logic replacement!
Comment #11
mattltThis patch looks like it's working better.
Thanks Joel!
Comment #12
joelpittetI'll take it:) Thanks, fixed and committed.