67044[TASK] Deprecate ControllerContext::getFlashMessageQueue()
Commit message
Review
-
Code review CR +2 Done
- Daniel Goerz +2
- Oli Bartsch +1
- Benni Mack +1
-
Verified V +2 Done
- Daniel Goerz +2
- Oli Bartsch +1
- Benni Mack +1
- TYPO3com +1 CI
Issues 1
Files 12
- typo3/sysext/beuser/Classes/Controller/PermissionController.php+1 −1
- typo3/sysext/extbase/Classes/Mvc/Controller/ActionController.php17+51 −1
- typo3/sysext/extbase/Classes/Mvc/Controller/ControllerContext.php+3 −0
- typo3/sysext/extbase/Tests/Unit/Mvc/Controller/ActionControllerTest.php+12 −7
- typo3/sysext/extensionmanager/Classes/Controller/AbstractModuleController.php+1 −1
- typo3/sysext/filelist/Classes/Controller/FileListController.php+2 −2
- typo3/sysext/form/Classes/Controller/FormEditorController.php+1 −1
- typo3/sysext/form/Classes/Controller/FormManagerController.php+1 −1
- typo3/sysext/form/Classes/Domain/Finishers/FinisherContext.php+12 −1
- typo3/sysext/form/Classes/Domain/Finishers/FlashMessageFinisher.php+22 −1
- typo3/sysext/form/Classes/Domain/Runtime/FormRuntime.php+2 −1
- typo3/sysext/indexed_search/Classes/Controller/AdministrationController.php+1 −1
Review log 1925
-
Alexander Schnitzler uploaded patch set 1 12/07/20, 12:38
-
Alexander Schnitzler wrote 12/07/20, 12:39
Topic set to extbase -
TYPO3com voted on patch set 1 V -1 12/07/20, 12:49 Completed build in 11m 04s on Mon, 7 Dec, 12:49 PM Test Summary: 12 of 32654 failed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-7900
-
Alexander Schnitzler uploaded patch set 2 12/07/20, 12:50
-
TYPO3com voted on patch set 2 V +1 12/07/20, 12:59 Completed build in 08m 49s on Mon, 7 Dec, 12:59 PM Test Summary: 32413 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-7902
-
Alexander Schnitzler uploaded patch set 3 12/07/20, 13:45
-
TYPO3com voted on patch set 3 V -1 12/07/20, 13:56 Completed build in 10m 57s on Mon, 7 Dec, 01:56 PM Test Summary: 31527 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-7904
-
TYPO3com voted on patch set 3 V +1 12/07/20, 14:25 Completed build in 51m 14s on Mon, 7 Dec, 02:25 PM Test Summary: 32413 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-7904
-
Oli Bartsch commented on patch set 3 12/07/20, 16:08
ActionController.php:188Why do we declare it nullable? AFAICS it will be set in the injectInternalFlashMessageService method. Problem with being nullable is that you have to check for null on every access then.ActionController.php:193UnresolvedSame as above.ActionController.php:867This direct access will then result in possible null pointer. -
Alexander Schnitzler commented on patch set 3 12/07/20, 16:25
ActionController.php:188ReplyYeah, that's walking on a thin line here. Technically, the property is not initialized on object construction (right after the constructor) and there is no guarantee the inject method is called. You can theoretically access this property before it's initialized and trigger a fatal error.ActionController.php:867ReplyIf properly constructed (via DI), this is not the case. If creation a controller via new and accessing internalFlashMessageService, a non initialized exception occurs. Question (imho) is what is closer to proper code according to the language specs. -
Oli Bartsch commented on patch set 3 12/07/20, 16:42
ActionController.php:188ReplyYes, that's basically also the case for all other properties which get injected. All of them will lead to an exception / error if accessed on an instance which is not yet not properly initialized.ActionController.php:867ReplySince this class heavily depends on proper construction with DI, I would actually prefer the "not initialized" exception here. I see no use-case on which it's valid that these properties are null. I mean, if this class is not properly constructed, this should trigger the error, not the null pointer in the later code. It would then be one more step to find the real cause. -
Alexander Schnitzler commented on patch set 3 12/07/20, 16:54
ActionController.php:188ReplyNo, it's not since the other properties don't have type hints.ActionController.php:867ReplyIt actually does. See this example: https://3v4l.org/ob66k If not properly initialized, a fatal error is thrown that tells you about the uninitialized property before php evaluates the method call which would throw a null pointer exception. That happens for uninitialized properties without type hint. -
Alexander Schnitzler commented on patch set 3 12/07/20, 17:02
ActionController.php:188ReplySorry, you are right of course...ActionController.php:867Replylol, that snippets proves me wrong actually. You are right of course. -
Oli Bartsch commented on patch set 3 12/07/20, 17:17
ActionController.php:188ReplySorry, what I meant was that the properties without type hint will lead to an "Call to a member function on null" error. This shows that having this class not properly initialized will lead to errors. No matter if nullable or not. And in this case I personally prefer an error telling me that some properties were not properly initialized instead of a null pointer.ActionController.php:867ReplyIt only does because it's not declared as nullable. Adding `private ?FlashMessageService $flashMessageService = null;` to your example leads to `Fatal error: Uncaught Error: Call to a member function getFlashMessageQueue() on null`. https://3v4l.org/BLHAK - That's what I personally want to avoid since the "must not be accessed before initialization" error takes you directly to the root cause. -
Alexander Schnitzler commented on patch set 3 12/07/20, 17:35
ActionController.php:188ReplyAckActionController.php:867ReplyYep, that's why it proves me wrong. I had the exact opposite in mind. Sometimes my brain doesnt work right. ^^ Will push a new patch set. -
Alexander Schnitzler uploaded patch set 4 12/07/20, 17:37
-
Alexander Schnitzler commented on patch set 4 12/07/20, 17:40
ActionController.php:867ReplyAck -
TYPO3com voted on patch set 4 V -1 12/07/20, 17:51 Completed build in 13m 38s on Mon, 7 Dec, 05:51 PM Test Summary: 32411 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-7932
-
Oli Bartsch commented on patch set 4 12/07/20, 18:09
ActionController.php:867ReplyNo problem. It's great that we could work that out! :) -
Alexander Schnitzler uploaded patch set 5 12/08/20, 08:47
-
TYPO3com voted on patch set 5 V +1 12/08/20, 08:56 Completed build in 08m 52s on Tue, 8 Dec, 08:56 AM Test Summary: 32411 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-7952
-
Benni Mack voted on patch set 5 V +1 CR +1 12/08/20, 16:07
-
Oli Bartsch voted on patch set 5 V +1 CR +1 12/09/20, 09:31
-
Daniel Goerz voted on patch set 5 V +2 CR +2 12/09/20, 09:38
-
Daniel Goerz merged patch set 6 12/09/20, 09:38