winter icon indicating copy to clipboard operation
winter copied to clipboard

Revisions not deleted automatically once related "revisionable" entity is deleted

Open lex0r opened this issue 4 years ago • 12 comments

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

  1. Create a revisionable model
  2. Save it to the database
  3. 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

lex0r avatar Sep 17 '21 15:09 lex0r

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.

github-actions[bot] avatar Nov 17 '21 00:11 github-actions[bot]

@bennothommo is this still in progress?

LukeTowers avatar Jul 15 '22 05:07 LukeTowers

@LukeTowers it hasn't been started yet. It's not a blocker though.

bennothommo avatar Jul 15 '22 05:07 bennothommo

@LukeTowers just to better understand the status of this - no fixes are planned in the foreseeable future? Even if the case, why closing?

lex0r avatar Dec 28 '23 23:12 lex0r

@bennothommo ?

lex0r avatar Jan 12 '24 11:01 lex0r

I still would like to look at this at some point.

bennothommo avatar Jan 12 '24 13:01 bennothommo

@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

LukeTowers avatar Feb 20 '24 17:02 LukeTowers

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 $revisionable property.
  • We need to make sure that such an action also works gracefully with the SoftDelete trait.

bennothommo avatar Feb 21 '24 01:02 bennothommo

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 $revisionable property.
  • We need to make sure that such an action also works gracefully with the SoftDelete trait.

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 avatar Mar 25 '24 23:03 lex0r

@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.

bennothommo avatar Mar 28 '24 01:03 bennothommo

I'm letting the bot close this the next time this comes up unless someone wants to action it in some way 😜

LukeTowers avatar Apr 25 '24 23:04 LukeTowers