85677[BUGFIX] Handle that FileLinkHandler:resolveFile() can return null
Commit message
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 76101
Show 5676 earlier messages
-
Thomas Hohn uploaded patch set 1 08/19/24, 07:04
-
core-ci voted on patch set 1 V +1 08/19/24, 07:10 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/63750
-
Thomas Hohn uploaded patch set 2
V +108/19/24, 07:59 -
core-ci voted on patch set 2 V -1 08/19/24, 08:07 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/63755
-
Stefan Bürk commented on patch set 2 08/19/24, 08:25
-
Thomas Hohn uploaded patch set 3
V -108/19/24, 10:02 -
core-ci voted on patch set 3 V -1 08/19/24, 10:07 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/63758
-
Thomas Hohn uploaded patch set 4
V -108/19/24, 10:15 -
core-ci voted on patch set 4 V +1 08/19/24, 10:22 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/63759
-
Thomas Hohn commented on patch set 4 08/19/24, 10:31
FileLinkHandler.php:102ReplyYes and no - the method calls createFileObject which has a rather funky return type - so I believe it's safest to do so. In addition I tried making getFileObject throw an FileDoesNotExistException - but for some weird reason that doesnt see to work - or maybe my test is wrong? -
Thomas Hohn commented on patch set 4 08/19/24, 17:40
FileLinkHandler.php:102ReplyDone -
Chris Müller updated the commit message in patch set 5
V +108/19/24, 17:53 -
Chris Müller updated the commit message in patch set 6 08/19/24, 17:53
-
core-ci voted on patch set 5 V +1 08/19/24, 17:59 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/63781
-
Markus Klein commented on patch set 6 08/19/24, 18:00
FileLinkHandler.php:103do we really need these specific checks? Simply checking for null should be sufficient, right? -
core-ci voted on patch set 6 V +1 08/19/24, 18:00 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/63782
-
Thomas Hohn commented on patch set 6 08/19/24, 18:52
FileLinkHandler.php:103ReplyI think I had that in one of the first versions but no sure if php was complaining over it -
Thomas Hohn uploaded patch set 7
V +108/19/24, 19:01 -
core-ci voted on patch set 7 V +1 08/19/24, 19:06 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/63784
-
Thomas Hohn commented on patch set 7 08/19/24, 19:08
FileLinkHandler.php:103ReplySo changes it to !== null - seems to work -
Markus Klein commented on patch set 7 08/19/24, 20:06
FileLinkHandler.php:95I think we can adjust the return type directly. We are narrowing down and not widening up.Important-104659-FileLinkHandlerResolveFile.rst:17to **a** type error -
Thomas Hohn uploaded patch set 8
V +108/19/24, 20:43 -
Thomas Hohn commented on patch set 8 08/19/24, 20:44
FileLinkHandler.php:95ReplyDoneImportant-104659-FileLinkHandlerResolveFile.rst:17ReplyDone -
core-ci voted on patch set 8 V +1 08/19/24, 20:50 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/63786
-
Thomas Hohn commented on patch set 7 08/20/24, 04:33
FileLinkHandler.php:103ReplyDone -
Andreas Kienast commented on patch set 8 08/20/24, 05:26
I wonder whether we need the ReST at all. `FileLinkHandler` isn't intended to be used directly, but is part of the upper Link Handler API and consumed by it.Important-104659-FileLinkHandlerResolveFile.rst:23Please do not describe the previous state as status quo as this isn't true anymore with your patch. Instead, describe properly what has changed and why it was necessary. -
Thomas Hohn uploaded patch set 9
V +108/20/24, 05:41 -
Thomas Hohn commented on patch set 8 08/20/24, 05:41
Important-104659-FileLinkHandlerResolveFile.rst:23ReplyDone -
core-ci voted on patch set 9 V +1 08/20/24, 05:46 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/63801
-
Thomas Hohn commented on patch set 9 08/20/24, 05:48
Reply
Since it's neither marked as public nor private - I find it ok ;-) -
Simon Schaufelberger updated the commit message in patch set 10
V +110/04/24, 12:13 -
Markus Klein voted on patch set 10 CR +1 V +1 10/04/24, 12:15
-
Simon Schaufelberger commented on patch set 10 10/04/24, 12:15
FileLinkHandler.php:110would it make sense to add some more context like the uid or the identifier? Then it would make sense to throw the exception above. -
Thomas Hohn commented on patch set 10 10/04/24, 12:31
FileLinkHandler.php:110ReplyDepends on if there is a case there $data doesn't contain an uid nor identifier - then you would still need the fallback FileDoesNotExistException. On the other hand you could provide a more specific context if you add the exceptions in the if blocks? -
core-ci voted on patch set 10 V -1 10/04/24, 12:31 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/67079
-
Simon Schaufelberger commented on patch set 10 10/04/24, 16:05
FileLinkHandler.php:110Replyyes, that is exactly what i mean. more context. that is why i would throw them above with a more detailed messsage. -
Thomas Hohn uploaded patch set 11
CR +1V +110/04/24, 17:25 -
Thomas Hohn commented on patch set 10 10/04/24, 17:36
FileLinkHandler.php:110ReplyDone -
core-ci voted on patch set 11 V -1 10/04/24, 17:41 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/67108
-
Thomas Hohn uploaded patch set 12
V -110/04/24, 18:11 -
core-ci voted on patch set 12 V +1 10/04/24, 18:29 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/67110
-
Markus Klein commented on patch set 12 10/04/24, 18:39
ResourceFactory.php:184How can this be `null`? `createFileObject` does not return `null`. What do I miss? -
Thomas Hohn commented on patch set 12 10/04/24, 20:18
ResourceFactory.php:184ReplyPHPStand complained about: 100 Strict comparison using === between TYPO3\CMS\Core\Resource\File and null will always evaluate to false. So it just might to be a == at L100 in FileLinkHandler and then revert the signature to @return File But my PHPStorm also is under the impression that getFileObject can return null even though I can see how that should happend -
Thomas Hohn commented on patch set 12 10/04/24, 20:22
ResourceFactory.php:184ReplyOr should the baseline be updated? -
Thomas Hohn uploaded patch set 13
V +110/05/24, 05:24 -
core-ci voted on patch set 13 V +1 10/05/24, 05:40 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/67131
-
Thomas Hohn commented on patch set 13 10/05/24, 05:43
ResourceFactory.php:184Reply@markus.klein@typo3.org - I hope this is better? -
Thomas Hohn uploaded patch set 14
V +110/05/24, 06:07 -
core-ci voted on patch set 14 V +1 10/05/24, 06:23 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/67134
-
Markus Klein commented on patch set 14 10/05/24, 20:52
FileLinkHandler.php:100I think phpstan is right here, this will never happen, as getFileObject either throws or returns a file. -
Thomas Hohn uploaded patch set 15
V +110/06/24, 06:11 -
Thomas Hohn commented on patch set 15 10/06/24, 06:24
FileLinkHandler.php:100ReplyKind of confused - now that I removed the check, the test fails and indicates that it can return null... -
core-ci voted on patch set 15 V -1 10/06/24, 06:28 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/67180
-
Markus Klein commented on patch set 15 10/06/24, 21:17
FileLinkHandler.php:100ReplyMaybe phpstan is wrong? wouldn't be the first time. -
Markus Klein commented on patch set 15 10/06/24, 21:22
FileLinkHandler.php:100ReplyAh, it's not phpstan. You mock the whole ResourceStorage, that means it will return null of course. -
Thomas Hohn commented on patch set 15 10/07/24, 05:25
FileLinkHandler.php:100ReplyIf you have time to help fixing/proposing how it can/should be fixed - I would appreciate that -
Markus Klein commented on patch set 15 10/07/24, 08:02
I studied the tests. IMO these unit tests are not really useful, they are not actually testing validity of identifiers/uids, due to ResourceFactory being mocked away. The only sensible way to test this would be a functional test. So we either add one there, or we drop the tests completely. -
Thomas Hohn uploaded patch set 16
V -110/07/24, 09:27 -
core-ci voted on patch set 16 V +1 10/07/24, 09:44 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/67216
-
Thomas Hohn commented on patch set 16 10/07/24, 09:47
Reply
Converted tests into functional testsFileLinkHandler.php:100ReplyChanges tests -
Thomas Hohn uploaded patch set 17
V +110/07/24, 09:48 -
Andreas Kienast commented on patch set 17 10/07/24, 09:51
Important-104659-FileLinkHandlerResolveFile.rst:6please add "throws exception" or alike to make it clear why it's important -
core-ci voted on patch set 17 V +1 10/07/24, 10:05 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/67217
-
Markus Klein commented on patch set 17 10/07/24, 10:12
FileLinkHandler.php:100ReplyAcknowledged -
Markus Klein commented on patch set 18
V +110/07/24, 10:13Published edit on patch set 17. -
Markus Klein commented on patch set 18 CR +1 10/07/24, 10:13
Important-104659-FileLinkHandlerResolveFile.rst:6ReplyDone -
Markus Klein commented on patch set 19
CR +110/07/24, 10:15Published edit on patch set 18. -
Markus Klein voted on patch set 19 CR +1 V +1 10/07/24, 10:16
-
Markus Klein commented on patch set 19 CR 0 10/07/24, 10:16
Important-104659-FileLinkHandlerResolveFileThrowsExceptionForInvalidFile.rst:45not sure about this FullyScanned. Nothing is scanned, right? -
Thomas Hohn commented on patch set 19 10/07/24, 10:26
Important-104659-FileLinkHandlerResolveFileThrowsExceptionForInvalidFile.rst:45ReplyWill change it to NotScanned -
Thomas Hohn uploaded patch set 20
V +110/07/24, 10:27 -
Thomas Hohn commented on patch set 20 10/07/24, 10:28
Important-104659-FileLinkHandlerResolveFileThrowsExceptionForInvalidFile.rst:45ReplyDone -
Markus Klein voted on patch set 20 CR +1 V +1 10/07/24, 10:36
-
core-ci voted on patch set 20 V +1 10/07/24, 10:36 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/67226
-
core-ci voted on patch set 18 V -1 10/07/24, 10:46 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/67223
-
core-ci voted on patch set 19 V +1 10/07/24, 10:47 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/67224
-
Simon Schaufelberger commented on patch set 20 10/07/24, 11:31
Important-104659-FileLinkHandlerResolveFileThrowsExceptionForInvalidFile.rst:14throws aImportant-104659-FileLinkHandlerResolveFileThrowsExceptionForInvalidFile.rst:42return -
Thomas Hohn uploaded patch set 21
CR +1V +110/07/24, 11:35 -
Thomas Hohn commented on patch set 21 10/07/24, 11:35
Important-104659-FileLinkHandlerResolveFileThrowsExceptionForInvalidFile.rst:14ReplyDoneImportant-104659-FileLinkHandlerResolveFileThrowsExceptionForInvalidFile.rst:42ReplyDone -
core-ci voted on patch set 21 V +1 10/07/24, 11:52 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/67230
-
Markus Klein voted on patch set 21 CR +1 V +1 10/07/24, 12:11
-
Simon Schaufelberger voted on patch set 21 CR +1 10/07/24, 12:29
-
Benjamin Franzke commented on patch set 21 CR -1 10/08/24, 05:46
`FileDoesNotExistException` is a exception that is meant to be thrown by the resource API, not as a way to structure consumers of the resource API by throwing this exception yourself. Sorry, this is -1 from my side. Returning null is just fine and can be handled easily in the calling code, otherwise an own exception would be an option as well (but `null` is better imho). -
Thomas Hohn uploaded patch set 22
CR +1V +110/08/24, 06:23 -
Thomas Hohn commented on patch set 22 10/08/24, 06:23
Reply
So changed it - hope this is better then 😊 -
core-ci voted on patch set 22 V +1 10/08/24, 06:28 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/67317
-
Andreas Kienast commented on patch set 22 10/08/24, 06:28
FileLinkHandler.php:92Why do we need this? We already have type declarations, this is superfluous. -
Thomas Hohn commented on patch set 22 10/08/24, 06:31
FileLinkHandler.php:92ReplyWill remove it then ;-) -
Thomas Hohn uploaded patch set 23
V +110/08/24, 06:31 -
Thomas Hohn commented on patch set 23 10/08/24, 06:31
FileLinkHandler.php:92ReplyDone -
core-ci voted on patch set 23 V +1 10/08/24, 06:39 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/67319
-
Christian Kuhn commented on patch set 23 CR -1 10/08/24, 11:43
on it. -
Christian Kuhn uploaded patch set 24
CR -1V +110/08/24, 11:57 -
Christian Kuhn uploaded patch set 25 10/08/24, 12:00
-
Christian Kuhn commented on patch set 25 10/08/24, 12:01
ResourceFactory.php:185this will be left out in v12 backport. -
Christian Kuhn commented on patch set 25 10/08/24, 12:01
ResourceFactory.php:185ReplyDone -
core-ci voted on patch set 25 V +1 10/08/24, 12:07 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/67371
-
core-ci voted on patch set 24 V +1 10/08/24, 12:07 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/67370
-
Stefan Bürk voted on patch set 25 CR +1 V +1 10/08/24, 12:12
-
Christian Kuhn voted on patch set 25 CR +2 V +2 10/08/24, 12:16
-
Christian Kuhn merged patch set 26 10/08/24, 12:16
FileLinkHandler.php:102