diff --git a/field_collection.module b/field_collection.module index 3a8f9e9..bb3381e 100644 --- a/field_collection.module +++ b/field_collection.module @@ -554,7 +554,11 @@ class FieldCollectionItemEntity extends Entity { $delta = $this->delta(); if ($this->item_id && isset($delta)) { unset($this->hostEntity->{$this->field_name}[$this->langcode][$delta]); - entity_save($this->hostEntityType, $this->hostEntity); + // Do not save when the host entity is being deleted. See + // field_collection_field_delete(). + if (empty($this->hostEntity->field_collection_deleting)) { + entity_save($this->hostEntityType, $this->hostEntity); + } } } @@ -1061,7 +1065,9 @@ function field_collection_field_delete($entity_type, $entity, $field, $instance, unset($ids[$id_key]); } } - + // Set a flag to remember that the host entity is being deleted. See + // FieldCollectionItemEntity::deleteHostEntityReference(). + $entity->field_collection_deleting = TRUE; entity_delete_multiple('field_collection_item', $ids); } }