Review 13.4 Merged

91353[BUGFIX] Prevent CLI cleanup:localprocessedfiles cleaning all files

Helmut Hummel CR +2 V +2 Easy +8 −11 updated 10/30/25, 08:11

Commit message

The CLI command "bin/typo3 cleanup:processedfiles" allows to
clean up resized / cropped / converted variations of media files,
by removing generated files which are no longer actively
referenced.

With #106002 a change was introduced that optimized directory
and file lookups with their "path generation". This lead to
duplicated "//" parts in the path that the cleanup command
uses to match referenced files with existing files.

Functional tests for this CLI command did not catch this
change in behaviour, because with the addition of the
"--all" option in #102582 those tests made wrong directory
assumptions, leading to ineffective checks to verify
only referenced files are removed.

This patch removes duplicate "//" path segments. This will
make the check for referenced files succeed again, and no
longer remove processed files which were still in use.
Previously, the presence of such segments in a path had been masked
(resolved) by using `SplFileInfo::getRealPath()`, which was
replaced in #106002 with `SplFileInfo::getPathname()`. See
[1] for more details on the variables

(Note that "processed files" can be regenerated like cache files,
when absent. This is a performance intensive operation though,
and not wanted when using the CLI command in a scheduler task
for example)

This patch also fixes the expectations and fixtures in the
related functional tests.

A duplicate call to SplFileInfo::isFile() is also removed by
this patch, as this verification is already executed
in the main loop of `getFilesOfFolderRecursive`.

[1] Details

Variables would for example contain:

- `$basePath` =  `/var/www/html/public/fileadmin/somethingelse/`
- `$folder->getIdentifier()` = '/_processed_/';

By using "ltrim()" here on the folder identifier, the leading
slash is removed and returns:

`/var/www/html/public/fileadmin/somethingelse/_processed_/`
  instead of:
`/var/www/html/public/fileadmin/somethingelse//_processed_/`

which would later be stripped to

`fileadmin/somethingelse/_processed_/...`
  instead of:
`fileadmin/somethingelse//_processed_/...`

Review

  • Code review CR +2 Done
    • Garvin Hicking +2
  • Verified V +2 Done
    • Garvin Hicking +2
    • core-ci +1 CI

Issues 4

Files 4

Review log 34

  1. Helmut Hummel commented on patch set 1 10/30/25, 07:25

    Cherry Picked from branch main.
  2. core-ci voted on patch set 1 V +1 10/30/25, 07:32 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/88080

  3. Garvin Hicking voted on patch set 1 CR +2 V +2 10/30/25, 08:11

  4. Garvin Hicking merged patch set 2 10/30/25, 08:11