hook_entity_create() should clearly state the entity is unsaved and mention the hook can be invoked for dummy entities

Created on 12 September 2022, over 2 years ago
Updated 28 April 2025, 6 days ago

API page: https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Entity%21...

The 'create' in hook_entity_create() doesn't mean 'saved for the first time'.

The docs say:

> This hook runs after a new entity object has just been instantiated.

but I think this could be made even clearer.

Something like:

> The entity has not been saved; to act on an entity being saved for the first time use hook_entity_insert().

The docs should also say that it's possible the hook to be invoked for dummy entities. Field UI module for example creates a new entity to show the 'default value' form element for a field.

🐛 Bug report
Status

Active

Version

11.0 🔥

Component

documentation

Created by

🇬🇧United Kingdom joachim

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇦🇺Australia acbramley

    Triaged as part of BSI, part of me wants to make this a task as it's just documentation clarification but I can see some people viewing this as a bug.

Production build 0.71.5 2024