Project

General

Profile

Actions

Bug #105217

open

RecyclerGarbageCollectionTask does not work recursively and stops at first sight

Added by S P about 2 months ago. Updated about 1 month ago.

Status:
Under Review
Priority:
Should have
Assignee:
-
Category:
scheduler
Target version:
-
Start date:
2024-10-07
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
12
PHP Version:
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

The RecyclerGarbageCollectionTask from ext:scheduler to cleanup file storage recycle folders (_recycler_, ROLE_RECYCLER) does not detect these recycle folders recursively, but only on first level (of the file storage root). Having them in sub-folders is totally possible (when using file mounts on subfolders, for example). And it also stops at first sight (there can validly be multiple recyclers, however).

$rootLevelFolder->getSubfolders() (which is used by the task to find the recycler folders) does allow setting an argument $recursive = true.

Actions #1

Updated by Garvin Hicking about 2 months ago

  • Category set to scheduler
Actions #2

Updated by S P about 2 months ago · Edited

Got some time to test this out. Two changes needed:
The inner loop must be (note the true argument at the end):

foreach ($rootLevelFolder->getSubfolders(0, 0, Folder::FILTER_MODE_NO_FILTERS, true) as $subFolder) {

(not sure about the filters, I just disabled them, because inside the loop the folders are selected for recycler folders anyways)

And the break inside the inner loop must be removed, so that it actually loops over all folders.

These both steps let the task cleanup all recycle bins, just like one expects from this task.

Or to put it all together, this is how the loop looks now in the patched RecyclerGarbageCollectionTask in my project:

foreach ($storageRepository->findAll() as $storage) {
    $rootLevelFolder = $storage->getRootLevelFolder(false);
    foreach ($rootLevelFolder->getSubfolders(0, 0, Folder::FILTER_MODE_NO_FILTERS, true) as $subFolder) {
        if ($subFolder->getRole() === $subFolder::ROLE_RECYCLER) {
            $recyclerFolders[] = $subFolder;
        }
    }
}
Actions #3

Updated by S P about 2 months ago

  • Subject changed from RecyclerGarbageCollectionTask does not work recursively to RecyclerGarbageCollectionTask does not work recursively and stops at first sight
  • Description updated (diff)
Actions #4

Updated by Sébastien Delcroix about 2 months ago · Edited

@S P

Could you please also test your changes with _recycler_ folders nested inside other _recycler_ folders if it crashes ?

Actions #5

Updated by Gerrit Code Review about 2 months ago

  • Status changed from New to Under Review

Patch set 1 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/86502

Actions #6

Updated by Gerrit Code Review about 1 month ago

Patch set 2 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/86502

Actions

Also available in: Atom PDF