Revisions not deleted automatically once related "revisionable" entity is deleted
Winter CMS Build
dev-develop
PHP Version
8.0
Database engine
MySQL/MariaDB
Plugins installed
No response
Issue description
When a revisionable model gets deleted (physically from the database) no related revisions of that model get deleted automatically from system_revisions.
Steps to replicate
- Create a revisionable model
- Save it to the database
- Delete it
Expected result: All related revisions should be removed
Actual result: Revisions remain in system_revisions
Workaround
No response
Any further details?
No response
This issue will be closed and archived in 3 days, as there has been no activity in the last 60 days. If this issue is still relevant or you would like to see it actioned, please respond and we will re-open this issue. If this issue is critical to your business, consider joining the Premium Support Program where a Service Level Agreement is offered.
@bennothommo is this still in progress?
@LukeTowers it hasn't been started yet. It's not a blocker though.
@LukeTowers just to better understand the status of this - no fixes are planned in the foreseeable future? Even if the case, why closing?
@bennothommo ?
I still would like to look at this at some point.
@lex0r if you're interested in getting this fixed I'd be happy to help by reviewing a PR or pointing you in the right direction
Just some thoughts on this if anyone (or myself) wish to take this on:
- Conventionally, a deletion action in most version systems is considered a "version" itself, ie. it can be reversed. Ideally, if someone wants previous versions of a deleted record to also be deleted, they should opt in to that behaviour - perhaps as a setting to the
$revisionableproperty. - We need to make sure that such an action also works gracefully with the
SoftDeletetrait.
Just some thoughts on this if anyone (or myself) wish to take this on:
- Conventionally, a deletion action in most version systems is considered a "version" itself, ie. it can be reversed. Ideally, if someone wants previous versions of a deleted record to also be deleted, they should opt in to that behaviour - perhaps as a setting to the
$revisionableproperty.- We need to make sure that such an action also works gracefully with the
SoftDeletetrait.
Implementing the above means some "initial state record" must be stored first. This is not the case as only deltas are tracked. Once a record is removed, we end up having no initial set of fields and only deltas that are absolutely useless as only partial information can be restored from them at best. Hence me creating this ticket to address this issue in the simplest way - getting rid of the unwanted data.
@lex0r that's a simple fix - the deletion step, if versioned, should contain the entire state of the model at that time. That way, it can be restored and then worked backwards.
I'm letting the bot close this the next time this comes up unless someone wants to action it in some way 😜