I just enabled the three PayPal modules on a Commerce Kickstart site and was following the installation instructions from the project homepage when I got a WSOD. After enabling error reporting I got the following message:

Fatal error: Unsupported operand types in /.../sites/all/modules/commerce_paypal/modules/wpp/commerce_paypal_wpp.module on line 50

I had just enabled the two payment rules and was trying to edit the action of the 'PayPal WPP - Credit Card' rule when the WSOD appeared (i.e. I was at this URL: http://example.com/admin/commerce/config/payment-methods/manage/commerce...)
It only happened for the WPP rule, the WPS one was fine.

Comments

rcharamella’s picture

I installed the module and got the same result. I then ran Update and found that Commerce had an update available. Once I updated Commerce, I was able to access the settings for PayPal WPP.

summit’s picture

Hi,

I have exactly the same fatal error:

PHP Fatal error: Unsupported operand types in sites/all/modules/commerce/contributed/commerce_paypal/modules/wpp/commerce_paypal_wpp.module on line 50.

I do not have an update available, so that is not a solution.

I think I found the solution! There was a typo with +=

  $settings += commerce_paypal_wpp_default_settings();

Should be:

  $settings = commerce_paypal_wpp_default_settings();

greetings, Martijn

dpolant’s picture

It seems like a better way to fix this would be to change the function definition

<?php
function commerce_paypal_wpp_settings_form($settings = NULL) {
?>

... to

<?php
function commerce_paypal_wpp_settings_form($settings = array() {
?>

That way there's no possibility of php trying to += a NULL and an array and getting upset. As I look at it there is probably a reason to use += rather than = because $settings might have something important in it when it is passed in.

rszrama’s picture

Priority: Major » Normal
Status: Active » Postponed (maintainer needs more info)

Hmm, we actually do want to use the += operator, but Commerce core is supposed to be fixed to always pass in a value here... can you confirm what what version of Drupal Commerce you're running if you're seeing the bug? If you're not on 1.2, please update (reading the release notes and running update.php - don't forget to backup) and let me know if the error still occurs?

rszrama’s picture

Status: Postponed (maintainer needs more info) » Fixed

I reviewed the core code again and confirmed that the plugin we added for payment method configuration will always send an array as the default value. Still, I don't know why we don't just use dpolant's suggestion to put the default as an array in the function signature. That alone wouldn't be enough to capture an error in the event that the function was called with a non-array value for the parameter, though. Interestingly, the WPS module gets around this by casting $settings to an array before unioning to the default values. That module doesn't use a separate function to define defaults, though, so I'm going to update that silliness so these two modules match.

Commit: http://drupalcode.org/project/commerce_paypal.git/commitdiff/14078e4

Status: Fixed » Closed (fixed)

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