Review main Merged Breaking

73868[!!!][TASK] Get rid of $_FILES in extbase

Susi Moog CR +2 V +2 Hard +286 −108 updated 01/17/24, 13:02

Commit message

The TYPO3 request already contains a "disentangled"
array of UploadedFile objects. With this change,
these UploadedFile objects are now used instead
of the superglobal $_FILES in extbase requests.

Additionally, the FAL ResourceStorage has been
adjusted for handling UploadedFile objects and
the ExtensionManager upload handling has been
adjusted.

The next step would be to further adjust FAL
to use only PSR provided methods for handling
uploaded files and to implement an API for file
uploads in Extbase.

Review

  • Code review CR +2 Done
    • Benni Mack +2
    • Stefan Bürk +1
  • Verified V +2 Done
    • Benni Mack +2
    • Stefan Bürk +1
    • core-ci +1 CI

Issues 1

Files 10

Review log 4156

Show 1931 earlier messages
  1. Susi Moog uploaded patch set 1 03/10/22, 11:28

  2. core-ci voted on patch set 1 V -1 03/10/22, 11:40 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/24788

  3. Susi Moog uploaded patch set 2 03/10/22, 11:52

  4. core-ci voted on patch set 2 V -1 03/10/22, 12:04 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/24789

  5. Susi Moog uploaded patch set 3 03/10/22, 13:28

  6. core-ci voted on patch set 3 V -1 03/10/22, 13:45 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/24797

  7. Susi Moog uploaded patch set 4 03/10/22, 14:51

  8. core-ci voted on patch set 4 V -1 03/10/22, 14:58 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/24798

  9. Susi Moog uploaded patch set 5 03/14/22, 07:57

  10. core-ci voted on patch set 5 V -1 03/14/22, 08:12 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/24865

  11. Susi Moog uploaded patch set 6 03/14/22, 11:23

  12. core-ci voted on patch set 6 V -1 03/14/22, 11:30 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/24872

  13. Stefan Bürk uploaded patch set 7 03/15/22, 09:55

  14. Stefan Bürk uploaded patch set 8 03/15/22, 10:01

  15. core-ci voted on patch set 7 V -1 03/15/22, 10:10 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/24903

  16. core-ci voted on patch set 8 V +1 03/15/22, 10:20 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/24904

  17. Susi Moog commented on patch set 8 03/15/22, 10:39

    @stefan thanks a lot!
  18. Susi Moog uploaded patch set 9 03/20/22, 08:47

  19. core-ci voted on patch set 9 V +1 03/20/22, 08:55 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/25004

  20. Susi Moog uploaded patch set 10 04/05/22, 06:39

  21. Susi Moog marked it ready for review 04/05/22, 06:42

  22. core-ci voted on patch set 10 V +1 04/05/22, 06:54 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/25466

  23. Benni Mack commented on patch set 11 04/05/22, 16:53

    Published edit on patch set 10.
  24. core-ci voted on patch set 11 V +1 04/05/22, 17:01 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/25546

  25. Benni Mack voted on patch set 11 V +1 CR +1 04/05/22, 17:03

  26. Andreas Kienast commented on patch set 11 CR -1 04/06/22, 07:48

    on it
  27. Andreas Kienast uploaded patch set 12 04/06/22, 08:05

  28. Daniel Goerz commented on patch set 12 CR +1 04/06/22, 08:12

    Looks very promising!

    UploadedFile.php:29

    Do we have to keep this @internal?
  29. core-ci voted on patch set 12 V +1 04/06/22, 08:14 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/25583

  30. Stefan Bürk commented on patch set 12 04/06/22, 23:01

    ResourceStorage.php:2120

    Are there planes to remove other `$_FILES[]` global usages too (kind of small epic) ? For example: * ExtendedFileUtility->replaceFile([...]) * DataHandler operations etc ? Then it would make sense to add at least here a @todo that `array` type should be deprecated after core usages are fully streamlined - or speaks something against it ?
  31. Simon Schaufelberger commented on patch set 12 04/07/22, 00:33

    UploadExtensionFileController.php:95

    can we document this somewhere so that people know how to use this feature?
  1. Stefan Bürk commented on patch set 12 04/07/22, 06:21

    UploadExtensionFileController.php:95 Reply

    I think a short example in Migration of the breaking-rst could be added.
  2. Susi Moog commented on patch set 12 04/08/22, 07:43

    UploadedFile.php:29 Reply

    At the moment I would leave it as internal at least during the v12 development phase so we can make sure that we have everything we need before we make it public API.

    ResourceStorage.php:2120 Reply

    At the moment, my plans are "just" about extbase and providing an API for handling uploads there, if we want to do this for every $_FILES usage, we should have an ApI for that.

    UploadExtensionFileController.php:95 Reply

    I'll add one, thanks for the suggestion :)
  3. Susi Moog uploaded patch set 13 04/08/22, 08:01

  4. core-ci voted on patch set 13 V -1 04/08/22, 08:11 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/25810

  5. Susi Moog uploaded patch set 14 04/08/22, 08:18

  6. core-ci voted on patch set 14 V +1 04/08/22, 08:29 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/25811

  7. Andreas Kienast uploaded patch set 15 04/08/22, 08:37

  8. core-ci voted on patch set 15 V +1 04/08/22, 08:46 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/25816

  9. Benni Mack commented on patch set 15 04/09/22, 19:46

    ResourceStorage.php:2120 Reply

  10. Benni Mack voted on patch set 15 V +1 CR +1 04/11/22, 21:03

  11. Stefan Bürk voted on patch set 15 CR -1 04/11/22, 21:11

  12. Stefan Bürk voted on patch set 15 V +1 CR +1 04/11/22, 21:28

  13. Stefan Bürk commented on patch set 15 04/11/22, 21:29

    UploadedFile.php:29 Reply

    Done
  14. Benni Mack commented on patch set 15 V +2 CR +2 04/11/22, 22:31

    UploadExtensionFileController.php:95 Reply

    Done
  15. Benni Mack merged patch set 16 04/11/22, 22:31

  16. Simon Schaufelberger commented on patch set 16 04/11/22, 23:02

    UploadExtensionFileController.php:95 Reply

    @Benni, not really. The example in the REST file is for the ResourceStorage, not for an actual extbase plugin. For an extbase plugin you need this line: $file = $this->request->getUploadedFiles()['extensionFile'] ?? null;
  17. Benni Mack commented on patch set 16 04/12/22, 11:27

    UploadExtensionFileController.php:95 Reply

    Sorry, misread this, Will do a followup.
  18. Susi Moog commented on patch set 16 04/12/22, 15:39

    UploadExtensionFileController.php:95 Reply

    Extbase still provides the uploaded file(s) as arguments, same as before - which is probably the documented way of using it; the extension manager however never really used that, so I did the least intrusive thing in this case, I'm unsure if we should recommend that though.
  19. Benni Mack commented on patch set 16 04/17/22, 12:40

    UploadExtensionFileController.php:95 Reply

    Thought about it a bit more: I think what we need is proper TypeConverters (one for persisting and one for "on-the-fly") that TYPO3 ships in Extbase, which are based on PSR-7 in the future. This then needs to be documented once we have the type converters. Issue is already available and could be continued now https://forge.typo3.org/issues/5718
  20. Andreas Kienast commented on patch set 16 03/31/23, 09:49

    post -1: regression in EXT:form

    RequestBuilder.php:206

    This line breaks the file upload in EXT:form.
  21. Christian Kuhn commented on patch set 16 07/31/23, 11:25

    RequestBuilder.php:206 Reply

  22. Andreas Kienast commented on patch set 16 07/31/23, 11:50

    RequestBuilder.php:206 Reply

    Yes
  23. Daniel Goerz commented on patch set 16 08/07/23, 08:29

    RequestBuilder.php:206 Reply

    I dont think the EXT:form patch is the "correct" fix. We should do the array_merge_recursive in the extbase RequestBuilder instead to have the uploaded files also available as arguments in the ActionController, so that we can map them on object properties via PropertyMapper. Or is there some reason for not doing that here?
  24. Torben Hansen commented on patch set 16 10/30/23, 09:35

    RequestBuilder.php:206 Reply

    I agree with Daniel, that the ext:form patch is not "correct". It fixes the problem for the ext:form scenario, but leaves out, that the uploaded files are not merged into the extbase arguments anymore. This basically results in, that currently every 3rd party code using on a custom `UploadFileReferenceConverter` (or even using the ext:form TypeConverter directly - which is discouraged) will not work, since uploaded files are not available for the property mapper and type conversion/file upload is non functional. Created an issue for this: https://forge.typo3.org/issues/102283
  25. Stefan Froemken commented on patch set 16 01/17/24, 13:02

    RequestBuilder.php:206 Reply Unresolved

    The count() comes from line 316 of old version. But it's only there, if a file was uploaded with just a property name like "image" insteadof "tx_events2_event.event.images.0". For me this issue is already solved with lines 198-201 here in new version. So, yes, the count() === 1 line has to be removed.