When deleting node, that has some field collection items, and enabled auto-creation of URL alias (pathauto module), the alias is not deleted from DB.

Steps to reporoduce:

- Enable pathauto
- Create node with field collection and "Generate automatic URL alias" checkbox checked.
- Delete node
- Search for row in {url_alias} with source "node/[nid]"

As I understand, the issue is deeper, than the troubles with pathauto module integration. My custom modules also keep its' info in DB for node deleted. I presume, that core book, forum and many contrib modules has similar issues with field collection items.

The reason is in host entity update, when field collection item is deleted. FieldCollectionItemEntity::delete() - triggers FieldCollectionItemEntity::deleteHostEntityReference(), which triggers node_save() for each field collection item in node. But why is deleting node saved each time? There is no needs to keep it updated during deletion process. It also has a performance issue - nodes, with >100 field collection items are deleted realy long, and there is a chance to get fatal error because of memory limit or execution time is exceeded. (This performance issue is actual for node update too)

I think this behaviour is wrong and should be fixed. It triggers node_update hook after node_delete hook was triggered for the same node! (@see node_delete(), short order: hook_node_delete(), field_attach_delete(), field_collection_field_delete(), node_save(), hook_node_update()) So, modules data is cleared in hook_node_delete() (as expected), but the next it is restored in hook_node_update()!

Comments

dewalt created an issue. See original summary.

dewalt’s picture

May be not whole node, but the field values only should be updated on FieldCollectionItemEntity::delete()? It can be done with field_attach_update() for node object clone with the target field isset only.

antiorario’s picture

Status: Active » Closed (duplicate)
Related issues: +#2385985: Deleting host entity causes save during deletion