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:
- _field_info_collate_types() gets called.
- entityreference gets enabled.
- commerce_affiliate_order gets enabled.
then the above Exception appears.
So to reliably reproduce this on a clean and minimal drupal install:
- Do a minimal drupal install
- drush en devel admin_menu commerce_customer commerce_line_item commerce_order commerce_price addressfield -y
- Run the following code in devel/php:
_field_info_collate_types(); module_enable(array('commerce_affiliate_order'));
Patch is coming.
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | commerce_affiliate-missing_ER_field-2383209-1.patch | 469 bytes | czigor |
Comments
Comment #1
czigor commentedThe attached patch clears the field_info cache before creating the entityreference field.
Comment #2
czigor commentedComment #4
deggertsen commented