Review main Merged

48080[BUGFIX] Catch exceptions while dumping a file

Wouter Wolters CR +2 V +2 Easy +7 −3 updated 11/15/16, 15:32

Commit message

While dumping a file in the frontend no exceptions are
caught. When a exception happens a 500 HTTP status is thrown.

Catch all exceptions to return the correct 404 HTTP status.

Review

  • Code review CR +2
    • Frans Saris +2
    • Stefan Neufeind +1
    • Markus Klein +1
    • Andreas Kienast +1
  • Verified V +2
    • Frans Saris +2
    • Markus Klein +1

Issues 1

Files 1

Review log 27

Show 2 earlier messages
  1. Wouter Wolters uploaded patch set 1 05/11/16, 14:16

  2. Wouter Wolters commented on patch set 1 CR -2 05/11/16, 14:17

    DO NOT REVIEW THIS!!!
  1. Wouter Wolters uploaded patch set 2 05/11/16, 14:30

  2. Wouter Wolters uploaded patch set 3 05/11/16, 14:34

  3. Wouter Wolters voted on patch set 3 CR 0 05/11/16, 14:35

  4. Frans Saris voted on patch set 3 CR +1 05/11/16, 14:36

  5. Markus Klein voted on patch set 3 CR +1 05/11/16, 14:37

  6. Markus Klein updated the commit message in patch set 4 05/11/16, 14:37

  7. Markus Klein voted on patch set 4 CR +1 05/11/16, 14:37

  8. Mathias Brodala commented on patch set 4 05/11/16, 14:47

    FileDumpController.php:65

    Should we log this exception instead of silently dropping it?
  9. Andreas Kienast voted on patch set 4 CR +1 05/18/16, 12:44

  10. Markus Klein commented on patch set 4 05/18/16, 12:44

    FileDumpController.php:65 Reply

    In this case I would not log anything. The caller receives a 404 that should be enough
  11. Tymoteusz Motylewski commented on patch set 4 05/18/16, 12:44

    FileDumpController.php:65 Reply

    +1 for logging
  12. Markus Klein voted on patch set 4 V +1 05/18/16, 12:44

  13. Wouter Wolters commented on patch set 4 05/18/16, 12:45

    IMO no logging, we do not log other 404 do we?
  14. Markus Klein commented on patch set 4 05/18/16, 12:46

    FileDumpController.php:65 Reply

    Your log will be spammed if the filerecord is gone, but still a valid link is around somewhere.
  15. Helmut Hummel commented on patch set 4 05/18/16, 12:46

    what exceptions are we talking about anyway? Why should the be caught? what is wrong with a 500 status?
  16. Helmut Hummel commented on patch set 4 05/18/16, 12:48

    FileDumpController.php:65 Reply

    I'd rather catch a filedoesnotexistexception (if that exists) than just any exception which might be appropriate to be thrown
  17. Helmut Hummel commented on patch set 4 CR -1 05/18/16, 12:50

    FileDumpController.php:65 Reply

    in fact Exception\FileDoesNotExistException is thrown in ResourceFactory::getInstance, thus we should only catch this and then a 404 header (without logging) makes indeed sense
  18. Wouter Wolters commented on patch set 4 05/18/16, 13:04

    FileDumpController.php:65 Reply

    See the hisotry of the patch please. I discussed this with Frans and changed the patch accordingly. I do not want any 500 exception shown to a website user. Thats why all exceptions are catched here no matter what exception is thrown.
  19. Helmut Hummel commented on patch set 4 CR 0 11/04/16, 12:32

    There are 3 point of views here: 1. from a user's point of view getting a 404 in any case seems good enough 2. from an application developers point of view hiding an error case (e.g. an exception in a driver) could mean hours of additional debugging because the error would be hidden with this commit 3. from an architectural point of view, it is wrong to emit a 404, if a resource is only temporarily not available. 404 means gone while 503 might be more appropriate depending on the reason But maybe in practice it might not harm to just throw a 404 and be done
  20. Markus Klein commented on patch set 4 11/04/16, 17:12

    @Helmut: 404 does not mean "gone", this is 410. 404 is defined as: "The requested resource could not be found but may be available in the future. Subsequent requests by the client are permissible." So this seems perfectly fine to me. Developer's view: Log an exception for the developer. But the question is, whether requesting arbitrary files is really a reason to log each request.
  21. Stefan Neufeind voted on patch set 4 CR +1 11/13/16, 12:50

  22. Frans Saris voted on patch set 4 CR +1 V +1 11/15/16, 11:52

  23. Frans Saris voted on patch set 4 CR +2 V +2 11/15/16, 15:31

  24. Gerrit merged patch set 4 11/15/16, 15:31

  25. Frans Saris commented on patch set 5 11/15/16, 15:32

    Cherry Picked This patchset was cherry picked to branch TYPO3_7-6 as commit d65da0cc3b19b70fe4a5677bec782e48a17450c0