silverstripe / silverstripe/developer-docs
Clarify usage of `delete()` on a versioned record
Nobody has claimed this yet.
- Dominant language
- No language data
- Stars
- 7
- Forks
- 74
- Avg merge
- 1d 14m
- Merged PRs (30d)
- 6
Description
The Unpublishing and archiving a versioned DataObject section of the versioning docs says this:
Call
doUnpublish()to unpublish an item. Either calldoArchive()or simply calldelete()to archive an item.
This strongly implies calling delete() will always automatically archive an item, but that's incorrect! That only works when calling the method on a draft record which has no published version.
Specifically, delete() deletes the record in the current stage. So if you're in the draft stage, you will remove the draft version (which may result in an orphaned live record). If you're in the live stage, you effectively unpublish the record.
Calling delete() directly might create weird version records though, so its use should probably be discouraged on versioned records, in favour of the appropriate method from the Versioned extension.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the “Unpublishing and archiving a versioned DataObject” section in the linked versioning documentation. Clarify that delete() removes the record in the current stage and can leave an orphaned live record, then explain when it behaves like unpublishing and recommend the appropriate Versioned method for versioned records.
Written by the indexing model from the issue text.
Assessment
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 65/100