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'];

Comments

ralt’s picture

Issue summary: View changes
Status: Active » Needs review
StatusFileSize
new1.11 KB

Patch attached to fix the remaining ones.

joelpittet’s picture

Title: Commerce Discount forcing LANGUAGE_NON » Commerce Discount forcing LANGUAGE_NONE
Version: 7.x-1.0-alpha3 » 7.x-1.x-dev
Status: Needs review » Reviewed & tested by the community

Seems like a reasonable fix.

bojanz’s picture

Status: Reviewed & tested by the community » Fixed

Committed, thanks.

  • bojanz committed 56fdb95 on 7.x-1.x authored by Ralt
    Issue #2055827 by Ralt: Commerce Discount forcing LANGUAGE_NONE
    
mattlt’s picture

Hello 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

bojanz’s picture

Status: Fixed » Needs work

Reverted the commit.

  • bojanz committed 6a6609e on 7.x-1.x
    Revert "Issue #2055827 by Ralt: Commerce Discount forcing LANGUAGE_NONE...
joelpittet’s picture

Oh sorry, I should have been more careful on that one, that's a major gotcha with entity_metadata_wrapper()

joelpittet’s picture

Status: Needs work » Needs review
StatusFileSize
new1.19 KB
new1.14 KB

This 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.

Note:

Prior to PHP 5.5, empty() only supports variables; anything else will result in a parse error. In other words, the following will not work: empty(trim($name)). Instead, use trim($name) == false.

joelpittet’s picture

StatusFileSize
new1.11 KB
new1.2 KB

And... with the right logic replacement!

mattlt’s picture

This patch looks like it's working better.

Thanks Joel!

joelpittet’s picture

Status: Needs review » Fixed

I'll take it:) Thanks, fixed and committed.

  • joelpittet committed dad51c9 on 7.x-1.x
    Issue #2055827 by joelpittet, Ralt, bojanz, mattlt, ShaneOnABike:...

Status: Fixed » Closed (fixed)

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