[6.x] Delete revisions when an entry is deleted - #15499
Open
ecomunicare wants to merge 3 commits into
Open
ecomunicare wants to merge 3 commits into
ecomunicare wants to merge 3 commits into
Conversation
Revisions and the working copy were left in the revisions store after an entry was removed. Delete them through the revision repository so the configured storage path and the Eloquent driver are both respected, and drop the entry directory once it is empty. Co-authored-by: Cursor <cursoragent@cursor.com>
Windows keeps backslashes from __DIR__, while the revisions store tidies paths to forward slashes, so the prefix assertion failed on that platform. Co-authored-by: Cursor <cursoragent@cursor.com>
jasonvarga
requested changes
Sep 23, 2026
jasonvarga
left a comment
Member
There was a problem hiding this comment.
Doing $entry->deleteQuietly() will delete revisions loudly, triggering all sorts of events. Please add a deleteRevisionsQuietly method that calls deleteQuietly on each Revision.
A quiet entry delete was still firing RevisionDeleted for each leftover revision and working copy. Follow the core withEvents pattern so those deletes stay silent. Co-authored-by: Cursor <cursoragent@cursor.com>
Author
|
Thanks @jasonvarga for your feedback! PR updated, now is handled properly, when an entry is deleted quietly, its revisions are also deleted quietly. And thanks to your patience too, it's our first contribution to the project ;) |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Deleting an entry left its revisions in storage. They live under collections/{collection}/{locale}/{id} in the revisions directory, which defaults to storage/statamic/revisions and can be changed with path in config/statamic/revisions.php or with STATAMIC_REVISIONS_PATH. The working copy is stored there too. After the entry was gone, those files were still on disk.
Entry::delete() now calls deleteRevisions() after the entry is removed and before EntryDeleted is dispatched. deleteRevisions() deletes each revision and the working copy through Revision::delete(), so RevisionDeleted still fires and Git keeps tracking the files. The file repository then removes the entry's revision directory once it is empty. The path comes from the revisions store, so a custom path is honored. Parent directories are left in place because other entries share them.
The same delete() path covers quiet deletes, collection deletes, and localized entries. Choosing to delete localizations removes each localization's revisions as well, because each one has its own revision key. If EntryDeleting cancels the delete, or the localizations are detached instead of deleted, their revisions stay.
The repository contract is unchanged. With the Eloquent driver, Revision::delete() uses that package's repository and removes the database rows. The empty-directory cleanup stays in the file repository and does not run for Eloquent.
Covered by tests for a normal delete, other entries left intact, a cancelled delete, deleteQuietly(), and a custom revisions path.