This is happening when saving a user account (Profile2 has some collections in it).

Exception: Unable to save a field collection item without a valid reference to a host entity. in FieldCollectionItemEntity->save() (line 400 of /modules/contrib/field_collection/field_collection.entity.inc).

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

NancyDru created an issue. See original summary.

NancyDru’s picture

BTW, only for the user themselves. User/1 can save with no error.

NancyDru’s picture

Anonymous’s picture

I have the same problem (message) when I try to update the module field collection from 7.x-1.0-beta11 to 7.x-1.0-beta12. The message appears when I run update.php

hazong’s picture

Hello
I have the same problem. Do you guys already find a solution?+
Cheers
Hermann

marco-s’s picture

I had the same issue with migrations. If a node was unpublished, field-collections hadn't access to the node and therefore to its host entity. My workaround was to run the migrations with the drush parameter --user=1.

But there's a query tag added to EntityFieldQuery which allows bypassing access checks. For more info see: DANGEROUS_ACCESS_CHECK_OPT_OUT query tag added to EntityFieldQuery

I've added this tag to the EntityFieldQuery in the fetchHostDetails() method of the field-collection module. Now I can run the migrations without the user 1. (using uid 1 is deprecated)

But I'm not sure about the security impact of this change. Maybe the maintainer can give more info about that?