After upgrading to Manual Crop 7.x-1.4 I'm getting a fatal error when I try to edit the commerce_price field on one of my products:

Fatal error: Unsupported operand types in /path/to/manual-crop/manualcrop.admin.inc on line 386

It looks like the manualcrop_supported_widgets($widget_type) check is failing. The assignment of $widget_type on line 377 doesn't match the structure I'm seeing in a var dump of the form element.

// Get the instance and widget type.
  $element = &$form['instance'];
  $widget_type = $element['widget']['type']['#value'];

Looks like it should be

// Get the instance and widget type.
  $element = $form['#instance'];
  $widget_type = $element['widget']['type'];
  • Drupal 7.17
  • Manual Crop 7.x-1.4
  • Commerce 7.x-1.4

Patch to follow.

Comments

garrettc’s picture

Status: Active » Needs review
StatusFileSize
new616 bytes
garrettc’s picture

Status: Needs review » Needs work

Hmm, this might not work. Some forms have #instance and some have just instance. I'm not quite sure what the difference between them is supposed to be.

matthijs’s picture

Assigned: Unassigned » matthijs
Status: Needs work » Fixed

Thanks for your patch, I ended up using:

$element = &$form[(isset($form['instance']) ? 'instance' : '#instance')];
$widget_type = $element['widget']['type'];

if (is_array($widget_type)) {
    $widget_type = $widget_type['#value'];
}

With this code both cases are covered ;-)

garrettc’s picture

Status: Fixed » Needs work

I'm still getting the error, but now with a different line number, on the latest dev (7.x-1.4+12-dev, 23rd November):

Fatal error: Unsupported operand types in /Users/garrettc/Work/sandbox/wdcs/sites/all/modules/Media/manual-crop/manualcrop.admin.inc on line 391

It still seems that the manualcrop_supported_widgets($widget_type) check is failing. Manual crop shouldn't need to add anything to a commerce_price field.

matthijs’s picture

Status: Needs work » Fixed

A better patch has been applied and committed.

garrettc’s picture

Status: Fixed » Needs work

Sorry, but it's still throwing the error, different line number again (7.x-1.4+15-dev, 2nd December)

Fatal error: Unsupported operand types in /Users/garrettc/Work/sandbox/wdcs/sites/all/modules/Media/manual-crop/manualcrop.admin.inc on line 387

matthijs’s picture

Weird, I tried this myself on a clean Commerce installation and the problem was fixed after applying the patch... I'll have another look at it!

Matthijs

matthijs’s picture

Status: Needs work » Active
garrettc’s picture

If it helps diagnose it I've just discovered that it's happening with commerce_giftaid fields too.

Anything else I can do to help just shout. I'm keen to get the upgrade installed.

matthijs’s picture

Status: Active » Needs review
StatusFileSize
new611 bytes

I'm sorry it took me a while, but could you try the attached patch? Thanks!

garrettc’s picture

It looks like it's working, thank you.

I applied the patch to the latest dev version (20th Dec) and edited the settings on both commerce_price and commerce_giftaid fields. No error.

matthijs’s picture

Status: Needs review » Fixed

Patch applied and committed! Thanks for your feedback!

Status: Fixed » Closed (fixed)

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