Review main Merged

77978[BUGFIX] Handle getFileContents in LocalDriver better

Thomas Hohn CR +2 V +2 Easy +2 −2 updated 03/01/23, 11:51

Commit message

The method getFileContents has return value string. But since
there is no guarantee that the file exists before calling
file_get_contents, a call to is_readable has been added.
This handles both the PHP Warning and ensures type correctness.

Review

  • Code review CR +2 Done
    • Christian Kuhn +2
    • Oliver Klee +1
    • JAKOTA Design Group GmbH +1
    • Simon Schaufelberger +1
  • Verified V +2 Done
    • Christian Kuhn +2
    • Simon Schaufelberger +1
    • core-ci +1 CI

Issues 1

Files 1

Review log 2124

  1. Thomas Hohn uploaded patch set 1 02/28/23, 09:08

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

  3. JAKOTA Design Group GmbH commented on patch set 1 CR +1 02/28/23, 09:51

    I was wondering about your suggestion, if that would get rid of the php warning as well.
  4. Thomas Hohn commented on patch set 1 02/28/23, 09:56

    Reply

    Hi - no - I removed that since I realised that it would not. The price for getting rid of it is the is_read() "overhead"
  5. JAKOTA Design Group GmbH commented on patch set 1 CR -1 02/28/23, 10:29

    Sadly this won't do. If $filePath is a external location like https://get.typo3.org/11.5.24 is_readable will always return false. But I'm not sure if this can even be the case here. I've just read the phpdoc above.
  6. Thomas Hohn commented on patch set 1 02/28/23, 11:03

    Reply

    If you look into calculateBasePath you will see that it's actually a path to a file and cant be an url
  7. JAKOTA Design Group GmbH commented on patch set 1 CR +1 02/28/23, 13:16

    You are right! And how could it be a URL? This is the LocalDriver...
  8. JAKOTA Design Group GmbH commented on patch set 1 02/28/23, 13:25

    LocalDriver.php:1354

    If for whatever reason file_get_contents returns false... is_readable($filePath) ? file_get_contents($filePath) ?: '' : ''; this should cover every scenario
  9. Thomas Hohn commented on patch set 1 02/28/23, 13:29

    LocalDriver.php:1354 Reply

    file_get_contents either returns false or the content ?: would return false positives depending on the content...
  10. Thomas Hohn uploaded patch set 2 CR +1 V +1 02/28/23, 13:50

  11. core-ci voted on patch set 2 V +1 02/28/23, 13:58 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/38212

  12. JAKOTA Design Group GmbH commented on patch set 2 CR +1 02/28/23, 13:58

    This should do the trick.
  13. JAKOTA Design Group GmbH commented on patch set 2 02/28/23, 19:50

    LocalDriver.php:1354

    But if you want to, you can simplify this again to return is_readable($filePath) ? (string)file_get_contents($filePath) : '';
  14. Thomas Hohn uploaded patch set 3 CR +1 V +1 02/28/23, 20:09

  15. Thomas Hohn commented on patch set 2 02/28/23, 20:09

    LocalDriver.php:1354 Reply

    Done
  16. Oliver Klee voted on patch set 3 CR +1 02/28/23, 20:14

  17. core-ci voted on patch set 3 V +1 02/28/23, 20:16 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/38234

  18. JAKOTA Design Group GmbH voted on patch set 3 CR +1 02/28/23, 20:19

  19. Simon Schaufelberger voted on patch set 3 V +1 CR +1 02/28/23, 23:40

  20. Christian Kuhn voted on patch set 3 V +1 CR +1 03/01/23, 08:35

  21. Christian Kuhn voted on patch set 3 V 0 CR 0 03/01/23, 08:47

  22. Christian Kuhn voted on patch set 3 V +1 CR +1 03/01/23, 10:12

  23. Christian Kuhn voted on patch set 3 V +2 CR +2 03/01/23, 11:51

  24. Christian Kuhn merged patch set 4 03/01/23, 11:51