Review 11.5 Merged

82999[BUGFIX] Handle falsy return type when getting selected folder

Andreas Kienast CR +2 V +2 Easy +4 −4 updated 02/15/24, 09:32

Commit message

The method `FileLinkHandler->getSelectedFolder()` may return either an
instance of `Folder` or a blunt `false`, where the latter case was not
properly handled. This issue is now fixed.

Review

  • Code review CR +2 Done
    • Andreas Kienast +2
    • Benjamin Franzke +1
    • Oli Bartsch +1
    • Oliver Hader +1
  • Verified V +2 Done
    • Andreas Kienast +2
    • Benjamin Franzke +1
    • Oli Bartsch +1
    • core-ci +1 CI

Issues 2

Files 2

Review log 1216

  1. Andreas Kienast uploaded patch set 1 02/14/24, 15:18

  2. Andreas Kienast updated the commit message in patch set 2 02/14/24, 15:18

  3. Andreas Kienast uploaded patch set 3 02/14/24, 15:30

  4. core-ci voted on patch set 1 V -1 02/14/24, 15:36 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/53198

  5. core-ci voted on patch set 2 V -1 02/14/24, 15:37 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/53199

  6. core-ci voted on patch set 3 V +1 02/14/24, 15:38 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/53200

  7. Oli Bartsch voted on patch set 3 CR +1 V +1 02/14/24, 16:01

  8. Markus Klein voted on patch set 3 CR +1 V +1 02/14/24, 16:15

  9. Benjamin Franzke commented on patch set 3 02/14/24, 21:01

    FileLinkHandler.php:126

    I'm very sorry; that was such a dumb mistake that I forgot to check the value in here while I added proper optional chaining in >= v12 :\ …especially given the fact that there already is an if condition in line 131. Ideally we would use `selectedFolder !== false && …` in here and assign `false` instead of `null` in the next line, since there is no reason in changing the value if it is already `false` and also no reason to mix both `false` and `null`. Assigning `null` is basically a left-over from the backport from v12 where `$selectedFolder` is typed as `?Folder` (and therefore optional chaining was used). I coudn't manage to reproduce the exception, therefore I did not yet update the code. Actually, thinking about this and the code in `getSelectedFolder()` a bit more and trying to avoid any possible additional bugs (due to XCLASSES or whatever), I'd even say we should opt for the same loosy check as in line 131 ``` if ($selectedFolder && $selectedFolder->getStorage()->isFallbackStorage()) ```
  10. Benjamin Franzke uploaded patch set 4 CR +1 V +1 02/14/24, 21:51

  11. core-ci voted on patch set 4 V +1 02/14/24, 21:59 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/53208

  12. Benjamin Franzke commented on patch set 4 02/14/24, 22:25

    FileLinkHandler.php:126 Reply

    Found a way to reproduce: getSelectedFolder() return false if backend user has no "default" upload folder, which is the case when all storages are marked non-writable. With that the error is actually reproducible in v11 when trying to create a new file link. … and therefore updated the patch (`=== false ||` was technically fine, but as I said I want to avoid any other regression because of xclasses or so).
  13. Oli Bartsch voted on patch set 4 CR +1 V +1 02/15/24, 08:54

  14. Oliver Hader voted on patch set 4 CR +1 02/15/24, 09:10

  15. Andreas Kienast voted on patch set 4 CR +2 V +2 02/15/24, 09:32

  16. Andreas Kienast merged patch set 5 02/15/24, 09:32