Review main Merged Breaking

80002[!!!][TASK] Harden FileInterface::getSize()

Alexander Schnitzler CR +2 V +2 Normal +57 −13 updated 07/18/23, 09:36

Commit message

While FileInterface::getSize() declared its return type to be
int only, the actual implementation AbstractFile::geSize()
returned int|null.

As the interface defines the contract, method signature of
AbstractFile::geSize() has been adjusted to only return int.

Meanwhile, to actually be a contract, return type declarations
have been introduced for said method.

Review

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

Issues 1

Files 4

Review log 1720

  1. Alexander Schnitzler uploaded patch set 1 07/11/23, 16:23

  2. Alexander Schnitzler wrote 07/11/23, 16:23

    Topic set to FAL
  3. Alexander Schnitzler marked it ready for review 07/11/23, 16:24

  4. Alexander Schnitzler wrote 07/11/23, 16:26

    Removed reviewer Stefan Bürk.
  5. core-ci voted on patch set 1 V +1 07/11/23, 16:31 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/44055

  6. Oliver Klee commented on patch set 1 V +1 07/11/23, 16:37

    FileInterface.php:48

    Nitpick: Please let's always have a space after the comma for readability. (Ditto in the implementing classes.)
  7. Alexander Schnitzler commented on patch set 1 07/11/23, 16:56

    FileInterface.php:48 Reply

    I actually find it harder to read, though. Except for array shapes. But fine with the change.
  8. Oliver Klee voted on patch set 1 CR +1 07/11/23, 17:13

  9. Alexander Schnitzler uploaded patch set 2 CR +1 V +1 07/11/23, 17:55

  10. Alexander Schnitzler commented on patch set 2 07/11/23, 17:56

    FileInterface.php:48 Reply

    Done
  11. Oliver Klee voted on patch set 2 V +1 CR +1 07/11/23, 18:00

  12. core-ci voted on patch set 2 V +1 07/11/23, 18:04 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/44059

  13. Oliver Klee commented on patch set 2 CR 0 07/12/23, 11:55

    Now that I think of it, maybe it would make sense to be able to differentiate between "the file is empty and hence has a size of 0" and "the size could not be determined". Would that make sense, and would it technically be feasible? What do you two think?
  14. Alexander Schnitzler commented on patch set 2 07/12/23, 13:14

    Reply

    I don't think the interface is responsible for telling the implementation what to do in case of errors. The contract is: Return file size as int. It only defines the positive path, exception can always occur. IMHO, null is not part of a positive path as null is not a valid size. I would go for the current approach and leave the implementation of error paths up to the implementation. Either return 0 because the size of a deleted file actually is 0 or throw an exception if further processing isn't possible. I also think that our implementation shouldn't throw an exception but return 0, even if a file is deleted. It's up to the calling code to handle the file status independently from its size. What if you want to list files (name, status, size)? Currently not easily possible because the implementation thinks it's important to throw an exception when 0 is a perfectly fine value for a deleted file...
  15. Oliver Klee commented on patch set 2 CR +1 07/12/23, 13:41

    After chatting about it, giving my +1.
  16. Stefan Bürk commented on patch set 3 CR +1 V +1 07/18/23, 09:10

    Published edit on patch set 2.
  17. core-ci voted on patch set 3 V +1 07/18/23, 09:17 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/44238

  18. Stefan Bürk voted on patch set 3 V +1 CR +1 07/18/23, 09:18

  19. Christian Kuhn voted on patch set 3 V +2 CR +2 07/18/23, 09:36

  20. Christian Kuhn merged patch set 4 07/18/23, 09:36