Issue Bug Resolved

#105217RecyclerGarbageCollectionTask does not work recursively and stops at first sight

S P 10/07/24, 10:39 updated 10/06/26, 11:15

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.

Reviews 3

History 511

  1. S P commented <span data-processor="relativetime" data-value="2024-10-08T05:47:55+00:00" > 10/08/24, 05:47 </span>

    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;
            }
        }
    }
  2. S P changed subject RecyclerGarbageCollectionTask does not work recursively RecyclerGarbageCollectionTask does not work recursively and stops at first sight description <span data-processor="relativetime" data-value="2024-10-08T07:48:22+00:00" > 10/08/24, 07:48 </span>

  3. Sébastien Delcroix commented <span data-processor="relativetime" data-value="2024-10-08T08:38:28+00:00" > 10/08/24, 08:38 </span>

    @stefanp

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

  4. Oliver Bartsch commented and changed status Under Review Resolved done 0 % 100 % <span data-processor="relativetime" data-value="2026-10-06T11:15:11+00:00" > 10/06/26, 11:15 </span>

    Applied in changeset commit:cbbc97eb2256c4c359abecdda1f3dd157209399c.