Hello!
Some time ago I began to receive such error messages:

Notice: Undefined index: module in _field_info_prepare_instance_widget() (line 382 of /var/www/sky37.pp.ua/public_html/modules/field/field.info.inc).
Notice: Undefined index: module in _field_info_prepare_instance_display() (line 350 of /var/www/sky37.pp.ua/public_html/modules/field/field.info.inc).

They appeared, when I tried to add new field, or new node type. Probably it is related to this core issue:
http://drupal.org/node/1001060
There are my report as well, more detailed:
http://drupal.org/node/1001060#comment-5027206
Most of affected people had problems because of contrib modules, which provide new field types (particularly Organic Groups). But that wasn't my case - error gone only after I disabled Entity Reference, and returned after I re-enabled this module. I tried to use repairing receipt from that issue - executed SQL query 'UPDATE field_config SET active = 0 WHERE module = "entityreference";', but it didn't help (though I didn't expect positive result, it was useful for people, who uninstalled some module and get problem after that).

It should be noted, that this problem appeared not from the beginning of my usage of Entity Reference module, but after some update (though I am not sure, was this module update, or core update - in D7.8 there are patch, which should solve this bug).

This issue is not reproducible on clean Drupal installation, so I'll be happy to provide any additional data. In case investigation will show, that there are no problems in core, please, let me know, so I could close related core issue again.

Comments

renat’s picture

Future investigation showed, that this error is caused by conflict between Entity Reference and Field collection. To reproduce it, you should install D7.8, Entity Reference 7.x-1.0-beta1 (and, consequently, entity (7.x-1.0-beta10) and ctools (7.x-1.0-rc1)) and Field collection 7.x-1.x-dev (from 2011-Sep-27). If all this modules were enabled, you'll start to receive error messages, when you try to create new node type, or add fields:

Notice: Undefined index: module in _field_info_prepare_instance_widget() (line 382 of /var/www/sky37.pp.ua/public_html/modules/field/field.info.inc).
Notice: Undefined index: module in _field_info_prepare_instance_display() (line 350 of /var/www/sky37.pp.ua/public_html/modules/field/field.info.inc).

It should be noted, that you haven't add Entity reference fields, nor create Field collections - simple installation is enough.

craigmc’s picture

Noticed this as well. Subscribing.

Damien Tournoud’s picture

Project: Entity reference » Field collection

I cannot see how Entity Reference could possibly be to blame. Happy to be proven wrong, anyway.

Reassigning to the field collection module as it seems to be the trigger of this.

adam_b’s picture

subscribing - I'm seeing this also

dgastudio’s picture

same here

30equals’s picture

same here

i only got this notice after i enabled entityreference though.
while tracing the error, my debugger told me that according to the call stack, the following lines in field_collection & entityreferene were called when the key 'module' was undefined for the display array in field.info.inc :

#57 in field_collection.module:
 foreach (field_info_fields() as $field_name => $field) {
#29 in entityreference.module:
'target_type' => ($entity_info = entity_get_info()) && isset($entity_info['node']) ? 'node' : key($entity_info),
ChrDr’s picture

same here. The message shows up >50 times.

Alan D.’s picture

Subs.

It only seems to appear when this combo of modules are enabled. Fairly easy to mimic, enable Field Collection 1.0-beta2 & Entity Reference 1.0-beta10. (BTW, I have only tried on existing sites with a million other modules)

renat’s picture

BTW, I have only tried on existing sites with a million other modules

Well, it is reproducible on clean installation with Entity Reference and Field collection.

fuse’s picture

+1

brianV’s picture

This is reproducible for us as well. A whole page full of errors.

Alan D.’s picture

Cross posted back into the Entity Reference issue queue: #1329354: (Cross-posting) Notice: Undefined index: module in _field_info_prepare_instance_widget()/_field_info_prepare_instance_display().

Hoping that one of the talented maintainers can have a look and resolve this issue. My own 30min look didn't discover anything new to report. :(

renat’s picture

Alan, this topic was initially started in Entity Reference issue queue, so it's maintainer is well aware of it.

Alan D.’s picture

It was a clear cross-post.

Sadly it is not possible to relate issues in the project issue queue any other way. This helps people looking for a solution. I discovered it after switching from References to Entity References. Is this a core issue, field collection issue, or an entity reference issue? It takes all three to generate the error.

Follow up on earlier comment. Debugging showed that it was first triggered on my install by the Global Redirect module early in the bootstrap process, although you (renat) ruled this out in #9.

busla’s picture

Issue tags: +relation

I´m using the Relation module and I got the same error messages after I upgraded to a dev version.

EvanDonovan’s picture

Title: Notice: Undefined index: module in _field_info_prepare_instance_widget() (line 382 » Notice: Undefined index: module in _field_info_prepare_instance_widget() (line 382) <- Incompatibility with Entity Reference

#8 is a helpful debug report, suggesting to me that there is some kind of circular reference going on between entityreference & field_collection which is causing field_info_widget_types() to return an empty array. (I determined that was what it had in the times when the 'module' index was undefined in _field_info_prepare_instance_display(). Note that the same function is being called in _field_info_prepare_instance_widget().)

Here's the order of the function calls when a new field is saved:

21: _field_info_prepare_instance_display
20: _field_info_prepare_instance
19: _field_info_collate_fields
18: field_info_fields
17: field_collection_entity_info_alter
16: drupal_alter
15: entity_get_info
14: entityreference_field_info
13: call_user_func_array
12: module_invoke
11: _field_info_collate_types
10: field_info_field_types
9: _field_write_instance
8: field_create_instance
7: field_ui_field_overview_form_submit
6: form_execute_handlers
5: drupal_process_form
4: drupal_build_form
3: drupal_get_form
2: call_user_func_array
1: menu_execute_active_handler

Possibly the problem is that entity_get_info() gets called in the definition of the entityreference field whereas field_collection calls field_info_fields() in the definition of the field_collection entity. There is apparently some kind of a conflict.

EvanDonovan’s picture

Appears to be resolved when I change line 29 of entityreference.module to the following:

'target_type' => 'node',

I don't think that is a problem generally, since node.module is almost always enabled. Could make the default 'user' if it is a problem.

So that's actually a fix on the Entity Reference side, not in Field Collection. Not sure if there's an analogous fix possible in Field Collection; the relevant line of code seemed more core to the module's functionality.

Alan D.’s picture

Fantastic work EvanDonovan!

BTW

modules/node/node.info
required = TRUE

So it would be a hacked core module if it was not enabled. For D8, user may be the only definite entity.

I can confirm that with the existence of the entity_get_info() function call, the error occurs, without this, the error disappears. I've pinged the cross-post to try and get feedback.

Alan D.’s picture

Patch for issue in EntityReference queue. Does this need more research into the real cause and effect? I think that this is more of a core issue rather than a contrib issue

Alan D.’s picture

Status: Active » Fixed

Evans fix has been committed in the Entity Reference queue.

Status: Fixed » Closed (fixed)

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

MICKtheBIG’s picture

To fix the notice in line 382 in fiels.info.inc I just did the following:

if (array_key_exists('module', $widget_type)) {
$widget['module'] = $widget_type['module'];
}else{
$widget['module'] = null;
}

I think this is fixed in the next release anyway. So why bother....