If a field collection item is deleted, any entities that reference that field collection will get a fatal error when an admin edits that entity when using the embedded field collection form:

EntityMalformedException: Missing bundle property on entity of type field_collection_item. in entity_extract_ids() (line 7410 of /shared/vash/sandboxes/reid/pin/www/includes/common.inc).

This is because field_collection_field_widget_form() does not validate that $field_collection_item is an empty variable before passing it into field_attach_form(). A simple check could prevent this error from happening and allow the references to be removed.

Related issues:
#1186826: Delete orphaned field_collection_item entities when they are (programatically) removed from the host entity
#1331764: Delete host entity reference when a field_collection_item entity is deleted programatically

Comments

dave reid’s picture

Status: Active » Needs review
StatusFileSize
new869 bytes
dave reid’s picture

Actually hold off on this. It doesn't quite allow the node to be saved.

dave reid’s picture

This is actually the proper fix.

tim.plunkett’s picture

Status: Needs review » Fixed
thomas_rendleman’s picture

David Reid. Thank you. I spent hours and two days trying to figure this one out. I am doing some HUGE queries. I even went from php 400M to 800M. Nothing worked until I read your post. Thank you again. Now I can get back to work...

Status: Fixed » Closed (fixed)

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