This might be a core issue but it can be handled on the module level.

I have an install profile having a dependency on commerce_affiliate_order. In some random stellar constellations I get a

FieldException: Attempt to create a field of unknown type <em>entityreference</em>. in field_create_field() (line 110 of xxx/modules/field/field.crud.inc).

I digged into this and found that commerce_affiliate_order_install() is the cause of the problem: it cannot see the entityreference field type it is trying to create. Which is very strange as the module has an explicit dependency on entityreference.

The source problem is that enabling entityreference does not clear the field_info cache reset the static $info variable of _field_info_collate_types(). So if in one page request the following things happen in the following order:

  1. _field_info_collate_types() gets called.
  2. entityreference gets enabled.
  3. commerce_affiliate_order gets enabled.

then the above Exception appears.

So to reliably reproduce this on a clean and minimal drupal install:

  1. Do a minimal drupal install
  2. drush en devel admin_menu commerce_customer commerce_line_item commerce_order commerce_price addressfield -y
  3. Run the following code in devel/php:
    _field_info_collate_types();
    module_enable(array('commerce_affiliate_order'));
    

Patch is coming.

Comments

czigor’s picture

Status: Active » Needs review
StatusFileSize
new469 bytes

The attached patch clears the field_info cache before creating the entityreference field.

czigor’s picture

Issue summary: View changes

  • deggertsen committed 0594f02 on 7.x-1.x authored by czigor
    Issue #2383209 by czigor: Attempt to create a field of unknown type...
deggertsen’s picture

Status: Needs review » Fixed

  • sinn committed 546a4b1 on 7.x-1.x
    Issue #2383209. Reverted last change
    

Status: Fixed » Closed (fixed)

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