Hello,

I have created a custom entity and a custom field of type "commerce_product_reference" (and an instance of this field for this entity).

Now I have this error showing up when disabling my module :
Invalid argument supplied for foreach() commerce_product_reference.module:810

The problem is commerce_product_reference_entity_info_alter() trying to alter the info of my "disabled" entity.

How to reproduce the problem :
- create a module implementing hook_entity_info(), thus creating a new entity ;
- create a field of type commerce_product_reference and the related instance, using commerce_product_reference_create_instance() or your customized code ;
- enable the module ;
- disable the module.

I think commerce_product_reference_entity_info_alter() should test whether $entity_info[$entity_type] exists or not (#810).

CommentFileSizeAuthor
#2 1482038-2.product_view_modes.patch1.77 KBrszrama
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

amateescu’s picture

Assigned: Unassigned » amateescu
Status: Active » Postponed (maintainer needs more info)

Can you please try to see if the patch from #1361562-6: Re-enabling Commerce causes a PHP Fatal Error also fixes your problem?

rszrama’s picture

Assigned: amateescu » Unassigned
Status: Postponed (maintainer needs more info) » Needs review
FileSize
1.77 KB

Looking into that entity info alter code, I see two things wrong:

  1. As the original poster implied, if a field instance was attached to a now disabled entity type, we're generating an error when we try to loop over $entity_info[$entity_type], because $entity_type is derived directly from the field_config_instance table.
  2. Additionally, we're creating view modes without checking to see if a field instance is deleted. There's a little column there for checking that, so I've added a condition on that column to the query.

Patch uploaded for the test bot.

rszrama’s picture

Status: Needs review » Fixed

Sweet. Committed.

Status: Fixed » Closed (fixed)

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