Entity save() in hook_ENTITY_TYPE_insert()

Created on 28 February 2024, 4 months ago

Problem/Motivation

The existing implementation of hook_ENTITY_TYPE_insert has two places where the entity is updated and saved. This is recursive and causes another round of calls to the presave and update hooks.

It is bad practice to save an entity while processing an insert or update hook. Changes to an entity should be done in a presave hook.

Proposed resolution

Add a new hook_ENTITY_TYPE_presave() and make the required updates there instead of in the insert hook.

πŸ› Bug report
Status

Needs review

Version

3.0

Component

Code

Created by

πŸ‡³πŸ‡ΏNew Zealand jlscott

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.69.0 2024