Document that entity business logic belongs in preSave(), postSave(), preDelete() and postDelete(), not save()/delete()

Created on 31 August 2013, over 11 years ago
Updated 10 February 2025, about 2 months ago

It is not guaranteed that save() or delete() are actually called when an entity is deleted. They're just a shortcut so that you don't have to get the storage controller manually. Especially for delete, it's common to call it directly on the storage controller, because that allows to delete multiple entities at once.

We need to document this, more than an entity type (e.g. Field) is currently implementing this incorrectly, other issues are trying to add stuff to save().

πŸ“Œ Task
Status

Postponed: needs info

Version

11.0 πŸ”₯

Component

entity system

Created by

πŸ‡¨πŸ‡­Switzerland berdir Switzerland

Live updates comments and jobs are added and updated live.
  • stale-issue-cleanup

    To track issues in the developing policy for closing stale issues, [Policy, no patch] closing older issues

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.

  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Thank you for creating this issue to improve Drupal.

    We are working to decide if this task is still relevant to a currently supported version of Drupal. There hasn't been any discussion here for over 8 years which suggests that this has either been implemented or is no longer relevant. Your thoughts on this will allow a decision to be made.

    Since we need more information to move forward with this issue, the status is now Postponed (maintainer needs more info). If we don't receive additional information to help with the issue, it may be closed after three months.

    Thanks!

  • πŸ‡¨πŸ‡­Switzerland berdir Switzerland

    Yes, this is still relevant, and it's still an issue. There are still core implementations that do it incorrectly such as Menu. save and delete methods really should be final, but I don't know if we have a process to announce that.

Production build 0.71.5 2024