Steps to reproduce the issue:
Delete the post.
Immediately permanently delete the post before the 5-minute waiting period is over.
The normal 5-minute waiting prompt appears.
After automatically returning, the following issue occurs: the deleted post is automatically restored to its undeleted state, requiring deletion again and then waiting another 5 minutes for permanent deletion.
1 like
Thanks for the report This will be fixed by
main ← fix/permanently-delete-undoes-soft-delete
merged 06:35PM - 23 Mar 26 UTC
When an admin soft-deletes a post then tries to permanently delete it before the… 5-minute timer expires, the server correctly returns a 403. However, the client-side error handler calls `undoDeleteState()` which clears `deleted_at` and restores the post to a non-deleted state in the UI — even though it remains deleted on the server. The admin then has to delete it again and wait another 5 minutes.
This happens because `destroy()` always calls `setDeletedState()` before the AJAX request, overwriting `oldCooked` even when the post is already deleted. When the request fails, `undoDeleteState()` uses that stale `oldCooked` to revert the post to a non-deleted state.
The fix skips `setDeletedState()` in `destroy()` when `force_destroy` is set (the post is already deleted), and makes `undoDeleteState()` accept opts so it can bail early for `force_destroy` — centralizing the guard instead of repeating it at each call site.
https://meta.discourse.org/t/398938
4 likes