Wiki source code of Deleted Attachments and the Recycle Bin
Last modified by Eleni Cojocariu on 2026/09/18 15:29
Show last authors
| author | version | line-number | content |
|---|---|---|---|
| 1 | An attachment deleted from a Page is not thrown away. XWiki moves it to the attachment recycle bin, a bin of its own beside the one deleted Pages go to, which is what lets an older version of a Page keep the files it had and what [[restoring a deleted attachment>>doc:documentation.xs.user.base.page.view.history-tab.view-history.restore-deleted-attachment.WebHome]] takes it back from. [[Attachments>>doc:documentation.xs.admin.attachments.WebHome]] introduces the other choices an administrator makes about an attachment. | ||
| 2 | |||
| 3 | == Where deleted attachments are listed == | ||
| 4 | |||
| 5 | Everything in the bin is listed on one page of the wiki, which an administrator reaches directly: | ||
| 6 | |||
| 7 | {{code language="none"}} | ||
| 8 | http://<yourwiki>/xwiki/bin/view/XWiki/DeletedAttachments | ||
| 9 | {{/code}} | ||
| 10 | |||
| 11 | Each row gives the file, the Page it was attached to, when it was deleted and by whom, and one action: deleting it for good. | ||
| 12 | |||
| 13 | {{image reference="deleted-attachments-index.png" size="large" alt="The Deleted Attachments listing, with the delete action of each row in its Actions column"/}} | ||
| 14 | |||
| 15 | The listing has no action for putting a file back, in any version to date. An attachment comes back through the Page it belonged to, by [[rolling that Page back>>doc:documentation.xs.user.base.page.view.history-tab.view-history.restore-deleted-attachment.WebHome]] to a version from before the deletion. | ||
| 16 | |||
| 17 | == How long before an attachment can be deleted for good == | ||
| 18 | |||
| 19 | A file cannot be purged from the bin the moment it lands there, which leaves a window in which a deletion is still reversible. Two properties of ##xwiki/WEB-INF/xwiki.cfg## set that window, and they are not attachment settings: XWiki reads the same two for deleted Pages. | ||
| 20 | |||
| 21 | |=Property|=Default|=Who waits that long | ||
| 22 | |##xwiki.store.recyclebin.adminWaitDays##|##0##|An administrator, who may therefore purge straight away. | ||
| 23 | |##xwiki.store.recyclebin.waitDays##|##7##|Everyone else, who also needs the Delete right on the Page the file came from. | ||
| 24 | |||
| 25 | Neither line ships in ##xwiki.cfg##, so using them means adding them. Both are read at startup, so a change takes effect on the next restart. This is what makes everyone, administrators included, wait three days: | ||
| 26 | |||
| 27 | {{code language="none"}} | ||
| 28 | xwiki.store.recyclebin.adminWaitDays=3 | ||
| 29 | xwiki.store.recyclebin.waitDays=3 | ||
| 30 | {{/code}} | ||
| 31 | |||
| 32 | Until the wait is over, the row is listed without its delete action, so nobody can purge the file early by going round the listing. | ||
| 33 | |||
| 34 | [[Optional Store Features>>doc:documentation.xs.admin.store.optional-features.WebHome]] is where the attachment recycle bin is switched off altogether, and where the store that holds what it keeps is chosen. |