Active
Project:
Drupal core
Version:
main
Component:
entity system
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
13 Aug 2018 at 21:54 UTC
Updated:
10 Apr 2026 at 16:02 UTC
Jump to comment: Most recent
Comments
Comment #2
effulgentsia commentedComment #3
gabesulliceDo these need to be hooks? Perhaps they can be events instead. Those two events could receive an immutable entity. That would help convey that the events are for doing things because an entity is about to be/has been saved vs. altering the entity during its save.
If so, I'd propose
before.saveandafter.saveas the event names.Comment #4
finex commentedI propose
hook_before_transactionandhook_after_transaction. (Otherwise pre/post are equivalent).Comment #5
wengerkI think we should keep the idea of decoupling insert & update and so we have to provide 4 hooks. I suggest this idea to prevent mixing the same hook to deal with before-insert & before-update - which are not the same .
I suggest using the same wording as existing: insert & update.
Insert
hook_entity_before_insert(event:before.insert)hook_entity_after_insert(event:after.insert)hook_ENTITY_TYPE_before_inserthook_ENTITY_TYPE_after_insertUpdate
hook_entity_before_update(event:before.update)hook_entity_after_update(event:after.update)hook_ENTITY_TYPE_before_updatehook_ENTITY_TYPE_after_updateI also encourage using events with hooks. The events are the most logical way to go on the future but to keep consistency we have to expose hooks too - on Drupal 8.
What do you think about it ?
Comment #9
skaughtThis issue is still relevant.
To mention, contrib offers hook_post_action. these namespaces seem like a good starting place..
Comment #10
jonathanshawIt's worth being aware that there are both existing issue for creating a single hook that covers both insert and update (but WITHIN the transaction: #2221347: Add hook_entity_postsave hook.
Comment #11
jonathanshawI had to adopt the hook_post_action module because I needed to do a node entity query from within a node insert/update hook and I was getting deadlocked.Comment #15
dpiComment #20
dqdFrom a glimpse, it seems issue #2965989: Does not work with core media in Automatic Entity Label's issue queue is on hold and needs direction based on the outcome of this issue here. Set this here as related from over there.