Enabling this module in conjunction with Field Collection causes lots of errors.

Firstly, at admin/structure/field-collections I get this on each page load:

> Notice: Undefined index: bundles in field_info_bundles() (line 584 of /Users/joachim/Sites/alice-drupal/modules/field/field.info.inc).

The problem seems to be that field_info_bundles() is going through the result of entity_get_info() and finding commerce_product and commerce_line_item... even though I don't have Drupal Commerce installed at all!!

Comments

joachim’s picture

When I enable the module I get:

Invalid argument supplied for foreach() field.info.inc:219 [warning]
Invalid argument supplied for foreach() field.info.inc:219 [warning]

(via drush)

And in the UI, a LOT of errors which start with:

Warning: Invalid argument supplied for foreach() in _field_info_collate_fields() (line 219 of /Users/joachim/Sites/alice-drupal/modules/field/field.info.inc).
Warning: Invalid argument supplied for foreach() in _field_info_collate_fields() (line 219 of /Users/joachim/Sites/alice-drupal/modules/field/field.info.inc).
Notice: Undefined index: label in entity_views_table_definition() (line 147 of /Users/joachim/Sites/alice-drupal/sites/all/modules/entity/views/entity.views.inc).
Notice: Undefined index: label in entity_views_table_definition() (line 147 of /Users/joachim/Sites/alice-drupal/sites/all/modules/entity/views/entity.views.inc).
Notice: Undefined index: controller class in entity_type_supports() (line 72 of /Users/joachim/Sites/alice-drupal/sites/all/modules/entity/entity.module).
Warning: class_implements() [function.class-implements]: object or string expected in entity_type_supports() (line 72 of /Users/joachim/Sites/alice-drupal/sites/all/modules/entity/entity.module).

I'm going to go out on a wild guess and say these are ALL to do with this module trying to add entity data to entities that aren't there!

joachim’s picture

Here's the culprit:

function inline_entity_form_entity_info_alter(&$entity_info) {
  $entity_info['commerce_product']['inline entity form'] = array(
    'controller' => 'CommerceProductInlineEntityFormController',
  );
  $entity_info['commerce_line_item']['inline entity form'] = array(
    'controller' => 'CommerceLineItemInlineEntityFormController',
  );
}

Removing this makes it all go away.

Now how best to fix it? We could stick an isset() around each one, but IMO if this is to be a general purpose module, it might be better in the long run to think about moving Commerce-specific hooks and classes to a submodule.

joachim’s picture

Title: causes errors in field_info_bundles() due to bundles that don't exist » causes errors in field_info_bundles() due to entities that don't exist
bojanz’s picture

Title: causes errors in field_info_bundles() due to entities that don't exist » Errors when Commerce is not enabled
Status: Active » Fixed

An isset is fine. Committed a fix.

Right now this module has no purpose outside of Commerce (the latest module to use it is commerce_discount).
Even if it did, the Commerce integration provides a nice example, and the Commerce specific hook is 9 lines of code long anyway,
not exactly the amount to warrant a submodule. So I have no plans to create one in the near future.

joachim’s picture

That's fair enough. I was thinking that you'd save on the classes too, but those are autoloaded anyway.

This module definitely has applications outside of Commerce! I've been having a tinker with getting nodes to work with it this afternoon :)

bojanz’s picture

This module definitely has applications outside of Commerce! I've been having a tinker with getting nodes to work with it this afternoon :)

Cool! Looking forward to the future.

Status: Fixed » Closed (fixed)

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