Merge conflict Gerrit cannot merge this change. It needs a rebase onto main.

Review main Work in progress Orphaned

81049[WIP][FEATURE] Allow missing local storage files to be handled by TYPO3

Stefan Bürk CR -1 V 0 Hard +920 −2 updated 04/21/26, 14:55

Commit message

This change removes the filadmin block from the
shipped root `.htaccess` to allow request for
not-existing local storage resource to be handled
by TYPO3.

A PSR-15 Middleware is introduced to check for
incoming request pointing to `Local` file storages
and responding with a simple and lightweight 404
response. The middleware dispatches the new PSR-14
`\TYPO3\CMS\Frontend\Event\MissingLocalStorageFileEvent`.

Test this change

Run a command in your clone of the TYPO3 Core. Then try what the change does and vote on Verified in Gerrit. How to review a patch

Check out patch set 15
git fetch https://review.typo3.org/Packages/TYPO3.CMS refs/changes/49/81049/15 && git checkout FETCH_HEAD
Cherry-pick onto main
git fetch https://review.typo3.org/Packages/TYPO3.CMS refs/changes/49/81049/15 && git cherry-pick FETCH_HEAD

Review

  • Code review CR -1 Needs a vote
    • Stefan Bürk -1
  • Verified V 0 Needs a vote
    • core-ci +1 CI

Issues 2

Files 12

Review log 2237

Show 612 earlier messages
  1. Stefan Bürk uploaded patch set 1 09/18/23, 15:01

  2. core-ci voted on patch set 1 V +1 09/18/23, 15:08 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/46679

  3. Stefan Bürk uploaded patch set 2 V +1 09/18/23, 16:54

  4. core-ci voted on patch set 2 V -1 09/18/23, 17:08 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/46692

  5. Stefan Bürk uploaded patch set 3 V -1 09/18/23, 18:11

  6. Stefan Bürk uploaded patch set 4 09/18/23, 18:13

  7. Stefan Bürk uploaded patch set 5 09/18/23, 18:19

  8. core-ci voted on patch set 3 V -1 09/18/23, 18:30 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/46698

  9. core-ci voted on patch set 4 V -1 09/18/23, 18:32 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/46699

  10. core-ci voted on patch set 5 V +1 09/18/23, 18:35 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/46702

  11. Stefan Bürk uploaded patch set 6 V +1 09/18/23, 18:52

  12. core-ci voted on patch set 6 V +1 09/18/23, 19:00 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/46706

  1. Stefan Bürk uploaded patch set 7 V +1 09/18/23, 20:32

  2. core-ci voted on patch set 7 V +1 09/18/23, 20:39 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/46711

  3. Stefan Bürk uploaded patch set 8 V +1 09/18/23, 21:28

  4. core-ci voted on patch set 8 V +1 09/18/23, 21:35 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/46719

  5. Stefan Bürk uploaded patch set 9 V +1 09/19/23, 09:37

  6. Stefan Bürk updated the commit message in patch set 10 09/19/23, 09:42

  7. core-ci voted on patch set 9 V +1 09/19/23, 09:44 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/46747

  8. Benni Mack commented on patch set 10 09/19/23, 09:45

    MissingLocalStorageFileEvent.php:30

    I would say it's a "RequestedFileNotFoundEvent"
  9. core-ci voted on patch set 10 V +1 09/19/23, 09:49 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/46748

  10. Oliver Hader commented on patch set 10 09/19/23, 11:34

    I like the idea. Maybe it's possible to prepare the new middleware for existing files as well (like "ext:secure_download"). For the time being, the implementation would just cover the missing-resource aspect (like done already).

    MissingLocalStorageFileHandler.php:55

    Just `Not found` (W3C)

    MissingLocalStorageFileHandler.php:80

    Check port (if given) as well. And what about the path part of the URI, like in `https://anyhost.it:8443/cms/fileadmin/`?

    MissingLocalStorageFileHandler.php:108

    In total might look like the following: ``` return ``` substr_count($a['storagePath']) <=> substr_count($b['storagePath']) ?: mb_strlen($a['storagePath']) <=> mb_strlen($b['storagePath']); ``` (`subst_count` replaces the explicit split & count)
  11. Stefan Bürk uploaded patch set 11 V +1 09/19/23, 11:36

  12. core-ci voted on patch set 11 V +1 09/19/23, 11:46 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/46765

  13. Stefan Bürk uploaded patch set 12 V +1 09/19/23, 11:47

  14. core-ci voted on patch set 12 V +1 09/19/23, 12:04 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/46766

  15. Stefan Bürk uploaded patch set 13 V +1 09/19/23, 14:50

  16. core-ci voted on patch set 13 V -1 09/19/23, 15:01 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/46797

  17. Stefan Bürk commented on patch set 13 09/19/23, 15:04

    Reply

    If the request uri directly matches existing files, they are handled by the Webserver before hand. Currently, only not existing directory or file requests are dispatched to TYPO3. `ext:secure_download` uses a prefix which would not find a local storage here anyway for know, and no handling would occure. However, I changed the class name for now to be more open for the future and added some todo comments into the code - for additional events. With additional events, I would become possible to resolve non-public storages through a dispatched event. Not sure if we can do it right here. Or with a routing configuration (which was a idea from Benjamin). We will see. If we could match a storage, and need to match a file in the storage after some transformations, we could further extend the middleware with additional event and handlings. I would say, that that could count as a prepartion. What would you say ? First goal was to be able to handle not-existing files with ext:redirects - or now additionally with the event in this middleware.

    MissingLocalStorageFileEvent.php:30 Reply

    Done

    MissingLocalStorageFileHandler.php:55 Reply

    Done

    MissingLocalStorageFileHandler.php:80 Reply Unresolved

    If a storage provides a full uri (baseUri) override, we are skipping it if it does not match the current request. Not sure, if we should just remove the check here and matching the path part only. I would keep the check(with the additional port check) for now, with the option to remove it later if we need to catch it here. The `path` part is checked later, no need to do it here.

    MissingLocalStorageFileHandler.php:108 Reply Unresolved

    Your comment on here looks weired. I changed the implementation. Hopefully it matches now what you meant.
  18. Stefan Bürk uploaded patch set 14 V -1 09/19/23, 15:06

  19. core-ci voted on patch set 14 V +1 09/19/23, 15:14 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/46798

  20. Benjamin Franzke commented on patch set 14 09/20/23, 11:32

    Important-101942-RemovedFileadminBlockFromRootHtaccess.rst:6 Unresolved

    Hm, this wasn't a block – it is rather an exclusion from URL rewriting. Maybe: "Allowed custom fileadmin URL rewriting for missing files via root .htaccess"

    Important-101942-RemovedFileadminBlockFromRootHtaccess.rst:16 Unresolved

    see above, they are not blocked, but excluded from URL rewriting.

    FileResolver.php:93 Unresolved

    is

    FileResolver.php:118 Unresolved

    extensions

    FileResolver.php:118 Unresolved

    handy

    root-htaccess:323 Unresolved

    The middleware has been renamed
  21. Stefan Bürk updated the commit message in patch set 15 V +1 09/20/23, 11:56

  22. Stefan Bürk commented on patch set 15 CR -1 09/20/23, 11:58

    Unresolved

    Delaying the patch - there are more things to check and pre-work needed: * SiteResolver - eventually redirect beforehand because of base and default language * Refactoring the determination into the SiteResolver directly * `sys_file_storage`: Migration to file as it is configuration and not content (+ deployable); or at least some kind of lookup cache to avoid database queries for pure storage configuration loadings. * ....
  23. core-ci voted on patch set 15 V +1 09/20/23, 12:03 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/46877

  24. Benni Mack marked it work in progress 04/21/26, 14:55

  25. Benni Mack wrote 04/21/26, 14:55

    Removed cc Benni Mack.