You are currently viewing TYPO3 File Recycler: (Un-)Delete your files

TYPO3 File Recycler: (Un-)Delete your files

One of the most hidden, but useful, features of TYPO3 is IMHO the file recycler. Yes, there is a recycle bin for files in the module “Filelist”. It is there since „ages“. I will show you the history of the feature, how to activate it in current releases and how to it resurrect for TYPO3 6.2.x.

File Recycler History

This recycler for files exists at least since TYPO3 4.4. The first blog post about the file recycler (https://www.lacisoft.com/blog/2010/07/22/how-to-create-a-recycle-bin-trash-feature-in-typo3s-fileadmin/), which I found, was published on July 22nd, 2010. TYPO3 4.4 was released one month before. Maybe this feature existed longer, but I did not want to check the repository in detail.

Somewhere on the way to FAL this nice feature got lost. The first bug report is over three years old (https://forge.typo3.org/issues/45327). Finally the fix made it into TYPO3 version 7. But it was not back ported to the 6.2 branch. There is a nice solution to get it working with TYPO3 6.2.

Before going into detail for the 6.2 solution, I’ll show you how to use it in 7.6 and 8.x (and 4.5, if you have it still in use).

Activation and Usage

There is no option in the backend, like in TSconfig or in user options to activate it, because it always there. The only thing you have to do, is to create a new folder in the module filelist named „_recycler_“. If this folder exists, every file, which resides on the same or a lower level and is deleted, will be moved to this folder. So it is possible to create cascading file recycle bins. This means: if a file is deleted from a file recycle folder and there is another one one or more levels above, it will be moved to this folder. Only if there is no other recycle folder above, the file will be finally deleted.
typo3worx_file-recycler

Filerecycler for TYPO3 6.2

As already said in the teaser, this function got lost while implementing the FAL stuff for 6.x. My first idea and approach was to backport the changes of TYPO3 V7 to 6.2 LTS. This works quite well, but has the drawback, that you must reapply the patch for each and every new TYPO3 6.2 release. If it is ok, you can download the patch at the end of this post.

While thinking about how we can do it better without all the manual patching, my colleague Dominique Kreemers (Twitter: @domi202) had a the brilliant idea to extend the class LocalDriver and to provide it via an extension. This approach has the advantage, that once installed, you don’t have to take care with each TYPO3 6.2.x update. The extension „fal_recycler“ is also linked at the end of this post.

For completeness I also created a repository at github for it. If you are interested in contributing, you will find it here: https://github.com/mschwemer/fal_recycler

It is not available in the TER, because TYPO3 6.2 is EOL in about half a year and I do not want to pollute it with a soon outdated extension. If there is enough demand, I might reconsider this decision.

[Update July, 27th, 2016]
Today I published the extension on the TER and on Packagist
[/Update]

Last … There is a little bug ;-)

Yes, there is a bug with all versions I tested: 6.2, 7LTS master, 8.3.0-dev. If you try to delete the recycler itself, it will lead to a fatal php error while renaming the _recycler_ folder. It is probably the same thing as at home: You cannot put the dustbin in itself. There is a ticket on forge for this issue … https://forge.typo3.org/issues/77091

[Update July, 27th, 2016] The bug was fixed on July 19th [/Update]

Downloads

So have fun deleting and restoring your files.

This Post Has 2 Comments

  1. Mathias Brodala

    You might want to update your article since that Forge issue has been resolved by now. :-)

Leave a Reply