Allow modules to prevent the entities's data records from being deleted

Created on 1 July 2019, almost 5 years ago
Updated 27 January 2023, over 1 year ago

Problem/Motivation

There is no (easy) way for modules to prevent an entity deletion from going through. Modules that want to implement a soft-delete functionality (like Multiversion) have to override the storage class for every entity type to achieve this.

Proposed resolution

Add a EntityStorageInterface::ENTITY_SOFT_DELETE constant/flag, which can be returned by hook_entity_predelete() implementations and will make the storage keep the database records.

This would help very much with a (re-)implementation of the soft-delete functionality in the Trash module, which is proposed for core inclusion: #2786135: WI: Phase E: Introduce Trash module β†’ .

Remaining tasks

- discuss/agree on the proposal
- write test coverage

User interface changes

Nope.

API changes

Nope.

Data model changes

hook_entity_predelete() implementations can now return EntityStorageInterface::ENTITY_SOFT_DELETE which will inform the storage to not delete the actual records from the database.

Release notes snippet

TBD.

πŸ“Œ Task
Status

Needs work

Version

10.1 ✨

Component
EntityΒ  β†’

Last updated about 18 hours ago

Created by

πŸ‡·πŸ‡΄Romania amateescu

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.

Production build 0.69.0 2024