create new tag
, view all tags

Feature Proposals » Empty Trash


Current State: Developer: Reason: Date: Concerns By: Bug Tracking: Proposed For:
UnderConstruction TimotheLitt AcceptedBy7DayFeedbackPeriod 2014-01-20   TWikibug:Item7422 KampalaRelease

Edit Form

DateOfCommitment:   Format: YYYY-MM-DD


Currently there is no web-based interface to empty the trash web. An admin needs to remove files on the shell level. For better usability and to make TWiki more appealing to non-technical users we need a GUI to empty the trash.

Description and Documentation

  • Trash-web's WebHome has an [empty trash] button
  • Which leads to a WebEmptyTrash page
  • This page lists all topics, each with a checkbox and topic summary
  • At top and bottom are check all / clear all checkboxes
  • Checkboxes are checked by default
  • A few system pages starting with Web* are shown grayed out and unchecked (disabled), e.g. they can't be deleted
  • Show [Delete selected topics] button at top and bottom
  • Javascript popup to confirm deletion: "Do you really want to delete the selected topics? This cannot be undone." [Delete] [Cancel]
  • If TrashAttachment is selected, all attachments on this topic are deleted. (For implementation, may be delete that topic and copy new one from a template topic.
Non-functional example:

Empty Trash

ALERT! Please note that emptying the trash is permanent, it cannot be undone!
ALERT! All attachments deleted by users are attached to the TrashAttachment topic. If you delete that topic, all attachments will be permanently deleted.

  Topic in Trash web Last update By
FooBarStuff Foo-bar stuff summary 2011-03-15 - 02:26 - r5 PaulReiber
MediaMind Media mind proposal 2011-04-02 - 13:42 - r3 EnriqueCadalso
TrashAttachment Deleted attachments
ALERT! This will permanently delete attachments deleted by all users
2011-03-14 - 12:00 - r2 GeorgeTrubisky
WebHome Trash web 2010-08-25 - 20:16 - r2 PeterThoeny
WebStatistics Statistics of Trash web 2011-04-09 - 23:55 - r298 TWikiAdminUser


The GlobalReplacePlugin has a GUI that could be taken for reference.

Contributors: PeterThoeny - 2011-04-09


There needs to be a way to empty the trash without logging into the server.

That method, as mentioned on ManagingTopics, is simply too time consuming and unacceptable to many corporate environments.

For the hardcore among you:

#find . -name 'Trash' -exec find {} -name '*,v' \; | xargs rm

-- MartinCleaver - 07 Oct 2003

I attach here a quick-and-dirty script I am using with crontab to empty the Trash all nights. Add a line like the following to your crontab to clean the trash all nights at 3 AM:

0 3 * * * (cd ~twiki/bin ; ./deltrash >/dev/null 2>&1)

NOTE: You must edit the script to suit your installation

-- AndreaSterbini - 07 Oct 2003

It would be nice if the script could use something like

find Trash -mtime +28

To only delete topics that were deleted more than a month ago, but with the actual time limit configurable from a TWiki topic or TWiki.cfg. I'm not sure if you wouldn't need some extra code to handle attachments with different modified dates than their topics though.

-- SamHasler - 10 Oct 2003

Thanks for that Andreas.

For portability, it'd be best as a Perl script. Is this something you could do Sam? I'd help you get it into CairoRelease if you did the bulk of the coding.

I'd start from the 'mailnotify' script.

-- MartinCleaver - 10 Oct 2003

I intend to bring emptytrash into DevelopBranch - any objections?

-- MartinCleaver - 22 Nov 2004

Having just tried that sh script I've come to the conclusion that it is dangerous. I no longer intend to bring it into DevelopBranch.

Anyone got a better script to offer as a base?

-- MartinCleaver - 14 Apr 2005

We may not want to delete the default topics (WebPreferences etc.). It is possible to write a script that :

  1. backups the default topics (the MANIFEST file could be used to get their list)
  2. deletes the Trash web then re-creates it
  3. copies the backup'd topics to the newly created Trash web
-- BenVoui - 01 May 2006

Sigh. I raised this as a bug/misfeature not so long ago, not realising that this was a longstanding issue. And, as it happens, if you delete all the files from a web, it is no longer recognised as a web. So a simple rm * is a really bad idea.

-- MeredithLesly - 02 May 2006

I see that some are wishing to empty the TWiki Trash like the trash from their Mailbox. But isn't it a very important aspect of the Wiki philosophy to have history available?

I mean, we might not only want to know the history of a still available topic but also of what's been written an discarded before. If you empty the Trash Web you are devalidating your TWiki history in fact.

That being said, of course anybody is free to do it the way it suits him best. There could be support maybe in the tools folder to empty the trash but as people often rather tend to delete then to think it shouldn't be a too obvious feature.

And anyway. I thought a Wiki was something to add content to and not to delete it from.

-- ManfredMislik - 31 Jan 2007

I basically agree; a wiki at the workplace is the corporate memory. Content gets obsolete over time, so a good way to ManageStaleContent is needed.

Disk space is cheap, a large Trash web is not that much of an issue. Once a year one could move the content of the Trash web to a sub-web, such as Trash.Trash2005, Trash.Trash2006, Trash.Trash2007, etc.

-- PeterThoeny - 01 Feb 2007

Not everyone uses cheap disk space Peter...

It appears that you have no interest in making trash removal accessible to the users. They can create, edit, move, do almost anything with the content but we can't trust anyone to empty the trash?

-- JohnWright - 20 Feb 2007

No update to this in 3+ years?!? This is still a major problem for reasons beyond the question of "stale" data. In my case, I tried using the AnyWikiDraw plugin to create a drawing attachment. It didn't work right and the issue seemed to be the attachment. A couple iterations of trying the plugin, then deleting the attachment to start fresh ran into the issue that I couldn't do the second delete (the file already existed in TrashAttachment). There appears to be no well-defined method of cleaning up the Trash to ensure that everything keeps working.

-- DavidMasterson - 2010-04-26

Removing duplicate attachments is tracked in TWikibug:Item5384 - we are still looking for a contributor to code a fix.

-- PeterThoeny - 2010-04-26

Resurrecting this from ParkedProposal to UnderInvestigation.

Useful feature. Spec of web-based interface needs TBD, for example showing a table with all attachments with a checkbox each, checked by default.

Anyone interested in defining spec and implementing this?

-- PeterThoeny - 2010-07-29

It'd be a hack, but... it'd be easy to run something to delete all topics NOT starting with "Web" in the Trash web. ..dunno if I'd call that a "spec" but I'd be happy to help implement it.

-- PaulReiber - 2011-02-14

I added the spec at the top of this topic.

-- PeterThoeny - 2011-03-15

This came up again in Support.HowToEmptyTrash.

-- PeterThoeny - 2011-11-27

For TWiki administrators, I believe this feature should be absolutely essential and I'm willing to work on this, time permitting.

Given this feature proposal, and Peter Thoeny's guidance to establish it as a plugin, I will be working to that end, to be supported on TWiki-5.1.0 and tested on Debian Linux 6.0.3 (Squeeze) with Perl v5.10.1.

Initial implementation will support deleting trashed attachments, with subsequent version(s) to support deleting trashed topics which is more complicated.

Probably the biggest security concern is that this will remove files directly from the file system, which is probably why so many people decided not to implement this.

To safeguard the file system, probably the easiest thing to do is to hard-code the location of trash attachments so it can only remove files from there, e.g.:


I will be reviewing ReadmeFirst to get started and will provide an initial implementation for review. Any pointers are appreciated. Thanks.

-- SergeiHaramundanis - 2011-11-27

How about rotating Trash instead of emptying?

Let's say we keep 5 Trash's. Then, we create a new empty Trash (probably from a _trash) after renaming Trash to Trash1 after renaming Trash1 to Trash2 after renaming Trash2 to Trash3 ... after deleting Trash5.

It would be done periodically (once a day or week) by a cron job.

-- HideyoImazu - 2011-12-02

Rotation could be done but I am concerned about increasing the complexity. For example, an extra step is needed to install a cron job, and extra docs and links are needed to access the rotated trash webs.

-- PeterThoeny - 2011-12-02

The concept of trash rotation seems to me contrary to the requested functionality:

1. allow easy, intuitive, permanent removal of artifacts from the repository 2. provide access to this functionality directly from the UI without external dependencies

This is the scope of the initial version, which can be extended in the future where it makes sense.

-- SergeiHaramundanis - 2011-12-03

I put the this feature request into "parked proposal" state and removed my name to signal another more committed developer to take the lead. I don't want to be a roadblock.

-- GeorgeTrubisky - 2011-12-06

Thank you Sergei for committing to implement this feature!

-- PeterThoeny - 2011-12-07

Apologies for taking a decade to get around to providing more info on implementing this.

Here's what I run for "empty trash" on reiber.org - far from perfect but it's better than nothing.

All files matching Web* should never be deleted even though they're in the trash. That's hard so I simplified it to all files not starting with W.

Regex improvements welcome but please ensure to have tested thoroughly.

<code> $ find data/Trash/ -type f -regex ^[^W]* -exec rm -f {} \; -print $ rm -f pub/Trash/TrashAttachment/* </code>

-- Paul Reiber - 2014-01-17

This is actually rather more complicated than indicated here. At least to get it right.

There are a lot of pitfalls, including the sad state of attachment metadata and dealing with the failure of various manual operations to update it. (E.g. the preceding find script doesn't delete attachments that go with deleted topics.)

I have a prototype that is (almost) alive. Look for it to show up as a plugin shortly. It is close enough to this approved feature that I'm inclined to hijack it.

I think that what I have is quite reasonable; I welcome feedback but will not get on the endless improvement treadmill or the religious discussion of whether it's a good idea as my time is limited. Others have asked for it. It's a plugin. If you don't want it, you turn it off .

I would be happier if it could get some pre-release testing (I run a version of TWiki that may be as old as this topic.)

Any volunteers?

I would also appreciate it if someone would volunteer to create an install script - it always seems to take longer than I have patience for. And I never use them, since they mess up permissions worse than installing by hand.

But since this belongs in the base distribution, it would be good to have it auto-installable.

-- Timothe Litt - 2014-01-20

Timothe & Sergei, please coordinate this work. (Sergei is getting active again.)

-- Peter Thoeny - 2014-01-20

That's unfortunate timing; his commit date was 2011-12-07, over 2 years ago. I've spent some borrowed moments over the past 2 days and produced something that I like.

I'm prepared to release EcoTrashPlugin in a few days. I'm still making minor tweaks, but it looks pretty solid - at least in my environment. More testing would be good. So would feedback, especially if I missed something major.

I have attached my working implementation, EcoTrashPlugin to this topic. You can download it from the link in the previous sentence. It works on 4.2.3 and has received basic testing on trunk. There are a few lines of code for backward/forward compatibility.

It has a strong dependency on the latest SpreadSheetPlugin. Things look very broken with older versions - I don't know what the break point is.

Feel free to install and test it - note that it deletes files, so make sure you have a valid system backup.

It has the usual plugin documentation topic as well as documentation on the GUI page. You must be in TWikiAdminGroup to use it. (Can be configured to any group.)

Sergi, I don't know what progress you've made, but you should at least have a look at this. It would be great if we could converge on one. My e-mail address is in the sources.

-- Timothe Litt - 2014-01-21

I have attached a couple of screen captures from EcoTrashPlugin. If you're really observant, you'll note that the pre-release code doesn't match these. I'll provide another pre-release when I'm done debugging. Enjoy.

Capture1.PNG Capture2.PNG

-- Timothe Litt - 2014-01-21

Looks great, Timothe!

On terminology, may be better using just "Topics" and "Attachments" in the tabs because the table heading is "Delete".

The "All" button might be better named "Select all" - use multi-span on that table row.

-- Peter Thoeny - 2014-01-21

As for plugin name, how about TrashManagerPlugin?

-- Peter Thoeny - 2014-01-21

Thanks for the feedback. I'm fussing with the look and feel.

On the name, I'd rather be ecologically correct. (The name is explained in the plugin doc topic...)

I'll think about the tab titles. I'm not sure how important it is to emphasize 'Deleted'. Maybe a heading "Trash web contents" above the tabs? I'll see how it looks.

"All" is actually a toggle. Click once, all boxes check. Click again, all clear. (And so on.) Saves a second button as well as keeping the width in line. There's hover text that clarifies the function.

Is there a way for me to tell the skin not to put the standard footing on the page? (E.g. it doesn't make sense to have edit, attach, etc - unless you're the maintainer.)

-- Timothe Litt - 2014-01-22

Here is a quick updated screeshot. It's hard to get a handle on it with a static picture; things adjust according to context.

The items in purple boxes are what I'd like suppressed on this kind of 'read only' topic. Editing/attaching will only cause trouble...


-- Timothe Litt - 2014-01-22

Never mind. Have JQuery, will travel. But it would be nice to have a better way.

(Yes, there's a way to get them back.)

By the way, this site isn't running the new WatchlistPlugin. I'm still getting spammed with my own edits....

-- Timothe Litt - 2014-01-22

On hiding edit & attach, see TopMenuSkin#Read_Only_Skin_Mode

-- Peter Thoeny - 2014-01-22

Thanks. I tried it. Works on trunk, not my production twiki. Caused another sidetrip setting the preference (I filed a bug).

However, on trunk I noticed that in read-only mode, View Topic actions on the top menu has 'History' and 'More Topic Actions' links active.

Yes, permissions should prevent using these functions, but read-only mode should probably hide them.

I should have a kit, even with an installer, shortly.

-- Timothe Litt - 2014-01-22

I think I tamed the build machinery. See EcoTrashPlugin. The doc is pretty complete, but not pretty.

Some screenshots of a full Trash web might be nice; mine can't be released.

If it catches on, I can move it from my private svn repository to trunk on twiki.org.

The installer upload probably should create the usual side topics (dev,appraisal - does anyone do appraisals anymore?)

I also noticed that it saved my password in .buildcontrib - which it created with world read. If you're going to save a password, at least set the file to u=rw,g=,o=!

Sergi, I'm still open to a merge if you have found better approaches or important things that I missed.

Peter, I found the install boilerplate lacking. You might look at what I did - it might be generally applicable.


-- Timothe Litt - 2014-01-23

Thank you Timothe for contributing this new plugin!! I'll provide feedback later at EcoTrashPluginDev.

Good point on password - best to file a report at TWikibug:BuildContrib.

-- Peter Thoeny - 2014-01-23

Thanks to Mr. Litt for spending the time to complete an initial version of the EcoTrashPlugin.

I haven't tested it yet, but it looks like it should meet the requirements, so unless there is additional functionality needed, I propose that the plugin be designated to address this issue.

-- Sergei Haramundanis - 2014-01-23

Since the concensus seems to be that EcoTrashPlugin meets the requirement, I'm changing the state (and committed developer) for this item. (Previous was SergeiHaramundanis, 2011-12-07).

SVN 26961 (2014-01-29) is more polished and addresses the feedback I received from Peter. It's released to the Plugins website.

Given the number of requests for this over the years, the release team should consider packaging it with the core.

-- Timothe Litt - 2014-01-29

Thank you Timothe! Yes, the new EcoTrashPlugin should be added to the core's standard plugins. Green light since this proposal is already accepted.

-- Peter Thoeny - 2014-01-29

Edit | Attach | Watch | Print version | History: r47 < r46 < r45 < r44 < r43 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r47 - 2014-01-29 - PeterThoeny
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2018 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.