I discovered this bug when adding features to an install profile that contain multiple relation types.

In relation_type_ensure_instance() you use field_info_instance to ensure the field instance isn't already created. But this function has some sort of caching mechanism and because of that the instance wasn't discovered. In field_create_instance the function field_read_instance is used to discover the existence of that instance (line 487), and does not have the caching issue. As it is now, I got the error Attempt to create an instance of field endpoints on bundle my_relation that already has an instance of that field.

CommentFileSizeAuthor
#1 1758860-1.patch623 bytesjelle_s

Comments

jelle_s’s picture

Status: Active » Needs review
StatusFileSize
new623 bytes

Attached patch fixes the problem.

mikran’s picture

Status: Needs review » Reviewed & tested by the community

Thanks a lot for the patch. It makes sense and I think I've seen other issues about this problem before. I'll commit soon.

mikran’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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

Paul B’s picture

Issue summary: View changes
Status: Closed (fixed) » Active
Issue tags: +Regression

This was fixed but it was reverted to field_info_instance() in #1936206: Relation install fails to add endpoint field to types provided by the defaults hook
It seems this can still cause errors:

#0  sites/all/modules/contrib/relation/relation.module(336): field_create_instance(Array)
#1  sites/all/modules/contrib/relation/relation.module(378): relation_type_ensure_instance('...')
#2  sites/all/modules/contrib/relation/relation.module(98): relation_get_types()
#3  includes/module.inc(1157): relation_entity_property_info_alter(Array, NULL, NULL, NULL)
#4  sites/all/modules/contrib/entity/includes/entity.property.inc(39): drupal_alter('entity_property...', Array)
#5  sites/all/modules/contrib/entity/views/entity.views.inc(445): entity_get_property_info('....')
#6  sites/all/modules/contrib/entity/views/entity.views.inc(387): EntityDefaultViewsController->schema_fields()
#7  sites/all/modules/contrib/entity/views/entity.views.inc(33): EntityDefaultViewsController->views_data()
#8  [internal function]: entity_views_data()
#9  includes/module.inc(951): call_user_func_array('entity_views_da...', Array)
#10 sites/all/modules/contrib/views/includes/cache.inc(90): module_invoke_all('views_data')
#11 sites/all/modules/contrib/views/includes/cache.inc(75): _views_fetch_data_build()

This happened while trying to rebuild the registry after the cache was already messed up because of other bugs (see #2085113: Class name must be a valid object in includes/common.inc on line 7809).

  • mikran committed f28c399 on 8.x-2.x authored by Jelle_S
    Issue #1758860 by Jelle_S: Fix caching issue in...