In a custom module I use
hook_node_presave($node) on node objects with referenced fields.
When creating a new node,
ddebug_backtrace() shows that
entity_save is called first and then
node_save. Which leads to two new nodes. At the end of
hook_node_presave() I have one correctly created node and one with only partially filled fields.
How can I prevent
node_save to fire in
entity_save was already executed? Or maybe the solution is to prevent
entity_save to fire?
Could anybody please explain how to correctly use
hook_node_presave() on node objects with attached referenced fields?