-
-
Notifications
You must be signed in to change notification settings - Fork 197
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow forced deletion of soft-delete models #1212
Comments
There is already a forceDelete() method: |
Also see the documentation: |
@mjauvin I'm sorry I wasn't clear enough about what I would like to see as a feature in Winter CMS. You are right about the existence of My request is about the gap that exists between There's an easy win to bridge this gap out of the box by allowing to |
You can easily add a button to your controller's <button
class="btn btn-default oc-icon-refresh"
data-request="onPurgeDeleted"
>REALLY DELETE
</button> And just add a public function onPurgeDeleted($id)
{
$this->formFindModelObject($id)->forceDelete();
} Am I missing something here? |
It's about developer productivity mostly. Imagine having to do the above in 5+ controllers, or instead have it out of the box accessible with:
|
@lex0r you could always use a trait to add it to multiple controllers |
Well yes, just that it becomes a little clumsy because I will have to override two methods from |
I thought would be nice for |
Feel free to submit a PR if you think this can be generic enough to be helpful to the masses |
I'm not opposed to us adding in a check for a |
@bennothommo any ideas for how to protect it from misuse? I wouldn't want to add it and allow it to be triggered by users without the developers realizing by simply including an extra parameter in the delete requests. |
The alternative would be to allow it to be configurable in the form config, if you didn't want it to be triggered by a parameter in the request. |
Can anyone provide some sample use cases here for us to consider? |
A potential use case would be for things that could be deleted (softly) elsewhere, but you wanted the Backend to be a place where an admin could permanently delete it, and instead of having to create a custom delete action or override the Form Controller's method, you just define that parameter in the form config. For example, I create a Comments plugin to leave comments on a page. I could allow a "delete" action for users to delete their own comments on the front-end, leaving a "deleted message" placeholder in its place, but I could also have a Backend page to review all comments (including deleted ones) with the ability to completely delete the comment if I wish. |
Package targeted
Winter CMS
Description
By definition, soft-delete enabled models are not expected to be permanently deleted. There's an exception to this rule, when developers rely on soft-delete as a sort of "inactive" attribute. Having such an attribute implies a possibility to "activate" at some point later (i.e. restore). Another possible operation for an "inactive" content may be actually a permanent deletion for the sake of good data housekeeping.
Of course the above can be achieved using an extra field like "status" or similar. This comes with some extra work needed to implement this, including a custom scope to hide inactive records. The amount of work needed is probably 95% repeats what is already available with soft deletion feature. So it comes down to the question - can soft delete cover the 5% change or that would be a form of featuritis?
It makes sense to extend the existing handling of soft-delete models to allow for a
forceDelete()
call on the model being deleted. This could be done with minimum modifications using an extra data parameter on the delete request (likepost('permanentDelete')
) insideFormController
's respective method.Will this change be backwards-compatible?
No response
The text was updated successfully, but these errors were encountered: