If an entity is created and there is no field set on the entity, there will be an error the user first loads the manage fields page. It will go away on refresh, but come back whenever the cache is cleared.

Notice: Undefined index: sparql_views_resource in field_info_instances() (line 685 of /Users/clark/Documents/sites/sparql-views-beta/modules/field/field.info.inc).

This is because _field_info_collate_fields() isn't reset when it is called in field_info_instances. If you add _field_info_collate_fields(TRUE) right above it (at line 679), there is no notice.

This is currently happening in at least 4 modules, SPARQL Views, OG Membership, Field Collection, and Messages.

#1119516: Notice on managing fields of a SPARQL Views resource type
#1069318: Notice: Undefined index: field_collection_item in field_info_instances()
#1097766: Undefined index: og_membership in field_info_instances()

Comments

yched’s picture

This is because _field_info_collate_fields() isn't reset when it is called in field_info_instances. If you add _field_info_collate_fields(TRUE) right above it (at line 679), there is no notice.

Except we don't want to rebuild _field_info_collate_fields() each time field_info_instances() is called, of course :-)

The _field_info_collate_fields() cache is supposed to be rebuilt :
- every time a new module is enabled, in order to catch newly exposed entity types and bundles,
see field_modules_enabled()
- and every time a new entity bundle gets dynamically created later on, *if* the module that defines the bundle properly calls field_attach_create_bundle

So my take is that the affected modules fail to call field_attach_create_bundle() when they create a new bundle for their entity type.

Anonymous’s picture

Status: Active » Closed (works as designed)

Ahhh, I got it. It's because Entity API recommends using hook_entity_info_alter instead of hook_entity_info to attach bundles for an entity. It does this because it wants to use entity_load to find the bundles, but that results in a recursion error in hook_entity_info.

I'll post this as an issue for Entity API. Thanks for the help, yched!

dave reid’s picture

This is actually a duplicate of #1245332: Warning when all bundles removed from an entity I believe.