After running cvs update this morning, I immediately started getting the repeated errors:

# Notice: Undefined index: view modes in _field_info_prepare_instance() (line 295 of /home/joshuarogers/drupal7/modules/field/field.info.inc).
# Warning: Invalid argument supplied for foreach() in _field_info_prepare_instance() (line 295 of /home/joshuarogers/drupal7/modules/field/field.info.inc).

Also, anything that is field no longer shows up. This includes node bodies.

After looking around for just a bit, it seems that the error is most likely coming from _field_info_collate_fields. Inside, field_read_instances is being called with no arguments, though the function itself has three required arguments and one optional. This bug effectively keeps all content (other than titles) from properly displaying.

Comments

catch’s picture

http://api.drupal.org/api/function/field_read_instances/7 doesn't have three required arguments, it has two optional ones. Did you mean something else?

Anonymous’s picture

Status: Active » Fixed

Hmm. It seems that I can't read (at least not before noon.) I'll try to find what I was looking at later when I get back to the house.

catch’s picture

Title: field_read_instances gets called from _field_info_collate_fields with no arguments » Notice: Undefined index: view modes in _field_info_prepare_instance()
Status: Fixed » Postponed (maintainer needs more info)

I've seen this error though, let's leave it a open for a bit to figure it out.

Anonymous’s picture

Status: Postponed (maintainer needs more info) » Active

I'm not actually sure what I was thinking for the first thing at top. I can only assume that I misread my trace. This time, I'm much more certain.

It seems that occassionally when _field_info_prepare_instance is called, $instance does not have a member 'entity_type'. When $instance['entity_type'] is used in a call to entity_get_info later in the function, NULL gets used instead (since it isn't defined.) entity_get_info returns a different value if entity_type is NULL. Thus, the foreach that expects $entity_info['view modes'] gets a different data structure passed to it.

Unfortunately, I'm not sure what is causing it to occassionally undefined.

yched’s picture

Guys, did you by any chance install and test #553298: Redesign the 'Manage Display' screen ? Fields created with this patch on will create such warnings when the code is back to current HEAD.

Anonymous’s picture

I've not applied any custom patches. That would have made everything easier though.

johnalbin’s picture

I'm seeing this bug as well. For the record, its been a while since I completely blew away my d7 database; I've been using update.php for a couple months now. And this error just popped up.

johnalbin’s picture

hmm… When I went to admin/structure/types/manage/article/fields, I get this PHP failure:

DOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'fci.entity_type' in 'where clause': SELECT fci.* FROM {field_config_instance} fci INNER JOIN {field_config} fc ON fc.id = fci.field_id WHERE (fci.bundle = :db_condition_placeholder_0) AND (fci.entity_type = :db_condition_placeholder_1) AND (fc.deleted = :db_condition_placeholder_2) AND (fci.deleted = :db_condition_placeholder_3) ; Array ( [:db_condition_placeholder_0] => article [:db_condition_placeholder_1] => node [:db_condition_placeholder_2] => 0 [:db_condition_placeholder_3] => 0 ) in field_read_instances() (line 856 of modules/field/field.crud.inc).

And, indeed, my field_config_instance table does not have an entity_type column.

Found #707724: Call them entities instead of objects where the database change was introduced.

So this will bite people who are going to be migrating from Alpha 3 to Alpha 4. Do we want to fix it?

For those people getting PHP notices/failures because of the DB change introduced with this patch, you can use the following query to fix it in MySQL:

ALTER TABLE field_config_instance CHANGE COLUMN object_type entity_type varchar(32) NOT NULL DEFAULT '';

You'll need to clear the cache too.

yched’s picture

D7 -> D7 upgrade path is not supported until we reach RC.

gravit’s picture

Category: bug » task
Priority: Critical » Minor
Status: Active » Closed (works as designed)

Thank you so much for tracking this down John - I ran into the same problem going from Alpha 3 to the Dev release when I needed to get the commits for views to not break the update.php routine...