The wastebin
The CMS comes with one module of its own, the wastebin, and every site has it: AddRelatudeCMS()
adds it. With it, what an editor deletes goes to a wastebin first, with everything below it in the
content tree. From there it can be restored, back where it was, or deleted for good.
It is turned off like any other module, in the CMS settings (Modules → Modules turned off:
wastebin). The CMS interface then deletes for good again.
The wastebin uses the database's own mark for a deleted node: the Deleted flag of the node's meta.
A node with the mark is left out of every query, relation end, count and search, unless the query
context asks for deleted nodes:
var all = db.Context.With(QueryContext.MasterAdmin.Deleted()).Create(); // reads what is in the wastebin tooThe node keeps its values, versions, files and relations. A restore only takes the mark away, so the node comes back with its links, in its place among its siblings.
What happens to content in the wastebin:
- Its page and files answer 404. A read by id, such as
db.Get(id), still finds the node. - It keeps its address. A new page with the same name gets
-2until the wastebin is emptied. - What went in together stays together. A page deleted with its children is one item. A child deleted before its page is an item of its own, and stays in the wastebin when the page is restored.
- A restore needs a place. When the page it was under is in the wastebin too, or gone, the editor chooses where it goes.
Some content is always deleted for good: users, user groups, sites and languages, which the database reads itself. So is a branch that holds a page the editor may not read.
The wastebin keeps things for 30 days. Its settings (Wastebin → Days kept) change that; 0 keeps
them until the wastebin is emptied. Older items are deleted for good when the site starts, every hour
after that, and when the job wastebin.empty-old runs.
In the CMS interface, Wastebin is in the menu while the module is on. It lists what is in it, newest first, with who deleted it and when. The content tree and the editor delete to it, and offer Delete for good as well. Only an administrator empties the wastebin.
The commands, for a plugin:
| Command | Payload | Does |
|---|---|---|
wastebin.check |
{ ids } |
whether the nodes can go in, and why not |
wastebin.bin |
{ ids, children?, relation? } |
puts the nodes in, each with everything below it |
wastebin.list |
{ search? } |
what the user may see in the wastebin |
wastebin.restore |
{ id, parent? } |
takes an item out, back where it was or into parent |
wastebin.delete |
{ ids } |
deletes items for good |
wastebin.empty |
{} |
deletes everything in it for good (an administrator) |
A large one runs as a process, which the user can follow, pause and cancel.