On sites with field collections, there seems to be an issue surrounding field_collection items where I ran into the following error:

Ashoks-MacBook-Air:public ashokmodi$ drush -l ossr.site.dev ecl
Begin caching comment                                                                                                                 [ok]
Begin caching field_collection_item                                                                                                   [ok]
WD php: Exception: Invalid field name given: field_version is not a Field Collection field. in                                        [error]
FieldCollectionItemEntity->__construct() (line 119 of
/Users/ashokmodi/Sites/drupal/ossr/public/sites/all/modules/field_collection/field_collection.module).
Exception: Invalid field name given: field_version is not a Field Collection field. in FieldCollectionItemEntity->__construct() (line 119 of /Users/ashokmodi/Sites/chillco/ossr/public/sites/all/modules/field_collection/field_collection.module).
Drush command terminated abnormally due to an unrecoverable error.                                                                    [error]

Needs some more investigation.

Comments

BTMash’s picture

Status: Active » Postponed (maintainer needs more info)

What I thought was an issue in caching field_collection_item does not seem to be an issue due to the script (I tried it on 2 other sites which use field_collection and it ran just fine). It seems to stem from an older field collection issue (#1084268: Exception: Invalid field name given. in FieldCollectionItemEntity) so it may be a case of the inherited site that just happened to have this issue. I'm postponing this issue in the event that perhaps more people just need to test this out if they run into similar issues.

BTMash’s picture

Status: Closed (works as designed) » Fixed

In my case, the solution ended up being http://drupal.org/node/1084268#comment-5881676 (there was stable field_collection_item data for a field that no longer existed). Once I removed that, everything was running correctly. So, problem existed elsewhere.

BTMash’s picture

Issue summary: View changes

Remove some unnecessary info.

BTMash’s picture

Status: Postponed (maintainer needs more info) » Closed (works as designed)

Status: Fixed » Closed (fixed)

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

stefan.r’s picture

Title: Field collection caching issue » Field collection items can exist in
Project: Drush Entity Cache Loader » Field collection
Issue summary: View changes
Status: Closed (fixed) » Active

I recently ran into a site with the same problem, where 6 deleted field collection items still existed in the field_collection_item table. I had to run the following commands in order to fix this as entity_delete on the orphaned item_ids would just give me an error:

db_query("DELETE FROM {field_collection_item} WHERE field_name NOT IN (SELECT field_name FROM {field_config} WHERE type = 'field_collection')");
db_query("DELETE FROM {field_collection_item_revision} WHERE revision_id NOT IN (SELECT revision_id FROM {field_collection_item})");

Should we add an update hook that does this? There is already an update hook that deletes orphaned items, perhaps something like this should have been in there?

stefan.r’s picture

Title: Field collection items can exist in » Orphaned field collection items can exist in field_collection_item table
Chris Charlton’s picture

How about just also documenting what [minimum] version of Field Collection doesn't get these errors?

FWIW, the site I ran ECL on was using field_collection-7.x-1.0-beta8. Ouch, that's old.

knalstaaf’s picture

I'm still getting these in the current dev (2016-Jun-23), upgraded from 7.x-1.0-beta11…

Still have to delete the remaining field in the field_collection_item table (in the db), and removing the field with the corresponding ID in field_collection_item_revision.

jmuzz’s picture

There is at least one currently known cause of this: #2763395: Field collection doesn't delete children data .

If anybody knows another way this can happen in the current dev please provide steps.

knalstaaf’s picture