silverstripe / silverstripe/developer-docs

Clarify usage of `delete()` on a versioned record

Open Beginner friendly
#878 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type/docs
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 call doArchive() or simply call delete() 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.