- 🇦🇹Austria alexh
Sorry to post in a closed issue. But I had the same issue and solved it, so I just want to share this with anybody who still would need it.
The error occurred in my setup when using also the Media Bulk Upload module → . I see that in that module entity_save is called three times, so I assume this is causing the multiple calls of hook_node_insert. Bulk Media Upload is unmaintained and I did not see how to fix the issue there.
But I saw two issues in the hook_node_insert implementation of this module:
- It accepts a node ID instead of a node object as parameter and then adds the auth key to the non-existing node object. I did not check if it is ever called with a nid instead of a node, but it is easy to fix that by loading the node in such case.
- It says to generate the key only if not set, but then inserts it also when it was already set. This creates the PDOException when the hook is called twice, so I think also the db_insert statement should be conditional.
Attached is a patch which addresses both issues and fixed the issue for me.
- Status changed to Needs review
about 1 year ago 12:03pm 30 August 2023 - 🇨🇦Canada joelpittet Vancouver
Thanks for getting back can you attach the patch you planned?
- 🇦🇹Austria alexh
Sorry for forgetting to provide the patch file and for not noticing this for a long while...eventually, the patch is attached here.