When trying to delete an order that has line items that point to products with commerce_file fields I get:

Error message
EntityMetadataWrapperException: Unable to load the commerce_order with the id 4792. in EntityDrupalWrapper->value() (line 697 of /home/rfay/workspace/commerce/sites/all/modules/entity/includes/entity.wrapper.inc). Backtrace:

EntityDrupalWrapper->value() entity.wrapper.inc:647
EntityDrupalWrapper->spotBundleInfo(1) entity.wrapper.inc:633
EntityDrupalWrapper->spotInfo() entity.wrapper.inc:323
EntityStructureWrapper->getPropertyInfo('owner') entity.wrapper.inc:385
EntityStructureWrapper->get('owner') entity.wrapper.inc:406
EntityStructureWrapper->__get('owner') commerce_file.entities.inc:895
commerce_file_license_revoke_line_item(Object) commerce_file.entities.inc:878
commerce_file_license_revoke_order(Object) commerce_file.module:689
commerce_file_commerce_order_delete(Object) 
call_user_func_array('commerce_file_commerce_order_delete', Array) rules.module:739
rules_invoke_all('commerce_order_delete', Object) commerce.controller.inc:26
DrupalCommerceEntityController->invoke('delete', Object) commerce.controller.inc:73
DrupalCommerceEntityController->delete(Array) commerce_order.module:658
commerce_order_delete_multiple(Array) commerce_order.module:645
commerce_order_delete('4792') commerce_order.forms.inc:338
commerce_order_order_delete_form_submit(Array, Array) form.inc:1389
form_execute_handlers('submit', Array, Array) form.inc:829
drupal_process_form('commerce_order_ui_order_delete_form', Array, Array) form.inc:349
drupal_build_form('commerce_order_ui_order_delete_form', Array) form.inc:187
drupal_get_form('commerce_order_ui_order_delete_form', Object) commerce_order_ui.orders.inc:67
commerce_order_ui_order_delete_form_wrapper(Object) 
call_user_func_array('commerce_order_ui_order_delete_form_wrapper', Array) menu.inc:503
menu_execute_active_handler() index.php:21

The order and related line items seem to be just fine.

Comments

recrit’s picture

Status: Active » Needs review

I have updated commerce_file_license_revoke_line_item() to resolve the order owner from the order object if it is passed to in. Previously it was getting the order from the line item object since this function is also used in line item deletion. Since on order delete the order is deleted already, it cannot be loaded from the order id anymore.

Please test and report back.
http://drupalcode.org/project/commerce_file.git/commitdiff/82cb613

rfay’s picture

rfay’s picture

Status: Needs review » Needs work

I was able to delete orders that were completed, but orders that are pending still give

EntityMetadataWrapperException: Unable to load the commerce_line_item with the id 8460. in EntityDrupalWrapper->value() (line 697 of /home/rfay/workspace/commerce/sites/all/modules/entity/includes/entity.wrapper.inc). Backtrace:

EntityDrupalWrapper->value() commerce_file.entities.inc:878
commerce_file_license_revoke_order(Object) commerce_file.module:689
commerce_file_commerce_order_delete(Object) 
call_user_func_array('commerce_file_commerce_order_delete', Array) rules.module:739
rules_invoke_all('commerce_order_delete', Object) commerce.controller.inc:26
DrupalCommerceEntityController->invoke('delete', Object) commerce.controller.inc:73
DrupalCommerceEntityController->delete(Array) commerce_order.module:658
commerce_order_delete_multiple(Array) commerce_order.module:645
commerce_order_delete('4790') commerce_order.forms.inc:338
commerce_order_order_delete_form_submit(Array, Array) form.inc:1389
form_execute_handlers('submit', Array, Array) form.inc:829
drupal_process_form('commerce_order_ui_order_delete_form', Array, Array) form.inc:349
drupal_build_form('commerce_order_ui_order_delete_form', Array) form.inc:187
drupal_get_form('commerce_order_ui_order_delete_form', Object) commerce_order_ui.orders.inc:67
commerce_order_ui_order_delete_form_wrapper(Object) 
call_user_func_array('commerce_order_ui_order_delete_form_wrapper', Array) menu.inc:503
menu_execute_active_handler() index.php:21
recrit’s picture

Status: Needs work » Needs review

This new error is cause by hook line item delete being called first, so then on hook order delete, the line item cannot be loaded anymore. Since the only information guaranteed to be there about the line item is line_item_id, I have updated the revoke function to accept an id also.

http://drupalcode.org/project/commerce_file.git/commitdiff/211dbe5

recrit’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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