After downloading the Stripe php library and the commerce strip module. I enable the module and get the following error:

Fatal error: Can't use method return value in write context in /code/sites/all/modules/commerce_stripe/commerce_stripe.module on line 1154 Call Stack:
0.0031 774472 1. {main}() /code/index.php:0
0.1950 59126664 2. menu_execute_active_handler() /code/index.php:21
0.1983 60389432 3. call_user_func_array:{/code/includes/menu.inc:527}() /code/includes/menu.inc:527
0.1983 60389768 4. drupal_get_form() /code/includes/menu.inc:527
0.1983 60390616 5. drupal_build_form() /code/includes/form.inc:131
0.4514 72671576 6. drupal_process_form() /code/includes/form.inc:386
0.6129 81341064 7. form_execute_handlers() /code/includes/form.inc:904
0.6129 81345096 8. system_modules_submit() /code/includes/form.inc:1520
0.6170 81630552 9. module_enable() /code/modules/system/system.admin.inc:1227
0.6176 81631800 10. drupal_load() /code/includes/module.inc:451

I'm using commerce 7.x-1.13 and Drupal 7.53. I am not using commerce card on file.

Comments

oheller created an issue. See original summary.

torgospizza’s picture

Category: Bug report » Support request
Priority: Critical » Major

Thanks for the report. This issue is caused by checking if the value returned is empty, and is something only seen in PHP versions prior to 5.5 as described here.

Can you verify what version of PHP you're using? You can check for this in the Reports area (/admin/reports/status).

We could fix this in the code itself, but my recommendation would be to upgrade your version of PHP, since PHP 5.4 is no longer supported and may open your server (and web application) to security issues. You should be on at least 5.5 or 5.6. See PHP.net for more details.

Worst case scenario: this is an easy fix, updating that line to check for the value on the wrapper instead of !empty().

oheller’s picture

torgosPizza, thanks for the quick response.
I thought I was using PHP 5.6.22, but I'm using PHP 5.3.29. I will update my PHP and report back if I'm having the same issue with the correct version of PHP.

oheller’s picture

After updating php 5.3 to 5.6. I was able to enable the module without the error.

oheller’s picture

Status: Active » Closed (works as designed)
torgospizza’s picture

Glad to hear you were able to upgrade. Please open another issue if you run into further trouble.

djpable’s picture

If this module "works as designed" this is not a good design for a module.
It's a 7.x module so it has to support all PHP version supported by Drupal 7.X.
Please reopen this issue.

It's not possible for me to upgrade PHP on my hosting, so i can't enable this module.

kingandy’s picture

Status: Closed (works as designed) » Needs review

Agreed, this seems important for 7.x compatibility.

FWIW #2 is correct, I was able to enable the module after editing line 1154 in commerce_stripe.module to

  if ($wrapper->__isset('commerce_cardonfile_profile') && $wrapper->commerce_cardonfile_profile->value()) {

torgospizza’s picture

Version: 7.x-3.0-alpha1 » 7.x-3.x-dev
Status: Needs review » Fixed

Thanks for confirming. I've made this fix in -dev.

This is the correct way of checking for a non-empty value anyway, so hopefully there are no other side effects.

Status: Fixed » Closed (fixed)

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