66553[TASK] Extbase controller actions must return ResponseInterface
Commit message
Review
-
Code review CR +2 Done
- Georg Ringer +2
- Torben Hansen +1
- Daniel Haupt +1
-
Verified V +2 Done
- Georg Ringer +2
- Torben Hansen +1
- Daniel Haupt +1
- TYPO3com +1 CI
Issues 1
Files 16
- typo3/sysext/belog/Classes/Controller/BackendLogController.php+4 −1
- typo3/sysext/beuser/Classes/Controller/BackendUserController.php+12 −4
- typo3/sysext/beuser/Classes/Controller/BackendUserGroupController.php+7 −2
- typo3/sysext/core/Classes/Http/JsonResponse.php+3 −0
- typo3/sysext/core/Classes/Http/Response.php+0 −2
- typo3/sysext/core/Classes/Http/ResponseFactory.php6+61 −4
- typo3/sysext/core/Classes/Http/ResponseFactoryInterface.php3new+28 −0
- typo3/sysext/core/Configuration/Services.yaml+3 −0
- typo3/sysext/core/Documentation/Changelog/master/Deprecation-92784-ExtbaseControllerActionsMustReturnResponseInterface.rstnew+89 −0
- typo3/sysext/extbase/Classes/Mvc/Controller/ActionController.php+33 −0
- typo3/sysext/extbase/Tests/Functional/Fixtures/Extensions/blog_example/Classes/Controller/BlogController.php+11 −14
- typo3/sysext/extbase/Tests/Functional/Fixtures/Extensions/blog_example/Classes/Controller/ContentController.php+3 −1
- typo3/sysext/filelist/Classes/Controller/FileListController.php+10 −3
- typo3/sysext/form/Classes/Controller/FormFrontendController.php+4 −1
- typo3/sysext/indexed_search/Classes/Controller/AdministrationController.php+18 −6
- typo3/sysext/indexed_search/Classes/Controller/SearchController.php+9 −3
Review log 2936
Show 711 earlier messages
-
Alexander Schnitzler uploaded patch set 1 11/06/20, 13:00
-
Alexander Schnitzler wrote 11/06/20, 13:02
Topic set to extbase -
TYPO3com voted on patch set 1 V -1 11/06/20, 13:11 Completed build in 10m 56s on Fri, 6 Nov, 01:11 PM Test Summary: 60 of 74036 failed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-7145
-
Alexander Schnitzler uploaded patch set 2 11/06/20, 13:12
-
TYPO3com voted on patch set 2 V +1 11/06/20, 13:25 Completed build in 12m 04s on Fri, 6 Nov, 01:25 PM Test Summary: 73551 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-7146
-
Alexander Schnitzler uploaded patch set 3 11/06/20, 14:53
-
Alexander Schnitzler wrote 11/06/20, 14:54
Hashtag added: PSR-7 -
Alexander Schnitzler wrote 11/06/20, 14:54
Hashtag added: PSR-17 -
Alexander Schnitzler uploaded patch set 4 11/06/20, 14:59
-
TYPO3com voted on patch set 3 V +1 11/06/20, 15:07 Completed build in 12m 55s on Fri, 6 Nov, 03:07 PM Test Summary: 73551 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-7151
-
TYPO3com voted on patch set 4 V +1 11/06/20, 15:17 Completed build in 14m 17s on Fri, 6 Nov, 03:17 PM Test Summary: 73551 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-7153
-
Alexander Schnitzler updated the commit message in patch set 5 11/07/20, 10:54
-
TYPO3com voted on patch set 5 V +1 11/07/20, 11:07 Completed build in 11m 58s on Sat, 7 Nov, 11:06 AM Test Summary: 73551 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-7164
-
Torben Hansen voted on patch set 5 CR +1 11/26/20, 11:32
-
Georg Ringer commented on patch set 5 11/26/20, 12:53
ResponseFactory.php:40shouldn't that be string as well? -
Georg Ringer commented on patch set 5 11/26/20, 14:37
hey Alex, thx for getting Extbase more into standards. some thoughts about that. I guess people won't like the overhead they will need in 11 do have no deprecations and in 12. now you need always to write `$this->responseFactory->createHtmlResponse($this->view->render());` comparing that to symfony it is vs `new Response($this->view->render())` So some questions: - coudldn't we have the return value nullable and then just do the `$this->responseFactory->createHtmlResponse($this->view->render());` inside extbase? - or what about something like `return $this->html()` which would call that -
Daniel Haupt commented on patch set 5 11/26/20, 20:28
> - coudldn't we have the return value nullable and then just do the `$this->responseFactory->createHtmlResponse($this->view->render());` inside extbase? I would also prefer this approach, not only to minimize migration work, but also to keep things simple as an `HtmlResponse` is the most common use case.ResponseFactoryInterface.php:25I would have expected this to return an `HtmlResponse` object. Is the thought false? -
Alexander Schnitzler commented on patch set 5 11/27/20, 07:32
> Patch Set 5: > > hey Alex, thx for getting Extbase more into standards. some thoughts about that. > > I guess people won't like the overhead they will need in 11 do have no deprecations and in 12. > now you need always to write `$this->responseFactory->createHtmlResponse($this->view->render());` That's not a nice solution, I agree. I talked to Benni and there are different philosophies about syntactic sugar and how it looks like. laravel has a different approach then symfony, both have pros and cons. > comparing that to symfony it is vs `new Response($this->view->render())` That's the approach I would like the most actually. Given the user just returns a plain response object, the framework assumes it's html and sets the Content-Type for you. IMHO that's the right amount of magic. > So some questions: > - coudldn't we have the return value nullable and then just do the `$this->responseFactory->createHtmlResponse($this->view->render());` inside extbase? That's contradictring the very idea of this patch. The goal is to have all actions reliably return a ResponseInterface because then we can enable dispatching requests to controllers that do not extend the action controller which currently takes care of developers lazyness. Also, $this->view->render() relies on a view object always being present. Something I want to change. views should be optional at some point, so people can write really slim controllers and actions. > - or what about something like `return $this->html()` which would call that I am fine with such an api although to me it feels strange because I don't return html. To me, html is a string, not a response object.ResponseFactoryInterface.php:25ReplyThere is no need for an implementation type hint because the responses don't have a different api. What makes a response an HtmlResponse is actually not the api but only its state. -
Alexander Schnitzler commented on patch set 5 11/27/20, 07:36
ResponseFactory.php:40Reply Unresolvedyes indeed. -
Alexander Schnitzler commented on patch set 5 11/27/20, 08:03
One thing I would like to add. This patch gives the impression that the usage of the response factory is necessary or even mandatory. It's not. People can easily just do > return new Response($this->view->render()); already. The factory is handy if your data source is not a string(stream) or if you don't want to set the default Content-Type yourself. I agree that the PSR is a very architectural approach here which is not necessarily the best user api. Also: We don't actually need Response, an HtmlResponse and a JsonResponse class. All those implement the ResponseInterface and don't offer a different api except for their controllers which do the job of said factory methods. Since all those classes are marked internal I would do the following: Deprecate the JsonResponse and HtmlResponse and have the user use helper methods to create a Response object with the right Content-Type. That's really the only difference between all those response objects currently. If we then only have this one Response object, we can offer the PSR-17 factory and those mentioned helper methods in the Extbase controller: > return $this->html(); or > return $this->htmlResponse(); Those methods are just syntactic sugar then, doing the view rendering magic and relying on the factory. We then have a PSR compatible api and syntactic sugar for the users. wdyt? -
Torben Hansen commented on patch set 5 11/27/20, 08:49
> Also: We don't actually need Response, an HtmlResponse and a JsonResponse class. All those implement the ResponseInterface and don't offer a different api except for their controllers which do the job of said factory methods. > > Since all those classes are marked internal I would do the following: Deprecate the JsonResponse and HtmlResponse and have the user use helper methods to create a Response object with the right Content-Type. That's really the only difference between all those response objects currently. Deprecating JsonResponse and HtmlResponse sounds reasonable to me. Although those classes are marked as internal, extension developers actually use those classes in public extensions. A public PSR-17 factory would be a good solution to handle the request object creation at a central place. > If we then only have this one Response object, we can offer the PSR-17 factory and those mentioned helper methods in the Extbase controller: > > > return $this->html(); > > or > > > return $this->htmlResponse(); > > Those methods are just syntactic sugar then, doing the view rendering magic and relying on the factory. > > We then have a PSR compatible api and syntactic sugar for the users. wdyt? Would be fine for me as long as the documentation explains the "magic" behind those methods. -
Alexander Schnitzler marked it work in progress 11/27/20, 08:51
-
Alexander Schnitzler commented on patch set 5 11/27/20, 08:52
Putting this patch in WIP mode again since we are discussing possible changes. -
Torben Hansen wrote 11/27/20, 09:00
Removed Code-Review+1 by Torben Hansen <derhansen@gmail.com> -
Alexander Schnitzler uploaded patch set 6 11/27/20, 14:35
-
TYPO3com voted on patch set 6 V +1 11/27/20, 14:46 Completed build in 11m 12s on Fri, 27 Nov, 02:46 PM Test Summary: 32394 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-7646
-
Alexander Schnitzler commented on patch set 6 11/27/20, 14:47
This change is ready for review. -
Torben Hansen commented on patch set 6 11/28/20, 06:20
ResponseFactory.php:24Is this still valid?ResponseFactory.php:40Should be "string $html" -
Daniel Haupt commented on patch set 6 11/28/20, 11:57
ResponseFactoryInterface.php:25ReplyThanks for your explanation. -
Alexander Schnitzler uploaded patch set 7 11/28/20, 13:49
-
Alexander Schnitzler commented on patch set 7 11/28/20, 13:50
ResponseFactory.php:24ReplyDoneResponseFactory.php:40ReplyDone -
TYPO3com voted on patch set 7 V +1 11/28/20, 14:00 Completed build in 10m 39s on Sat, 28 Nov, 02:00 PM Test Summary: 32394 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-7661
-
Torben Hansen voted on patch set 7 V +1 CR +1 11/29/20, 12:08
-
Daniel Haupt voted on patch set 7 V +1 CR +1 11/29/20, 13:13
-
Georg Ringer voted on patch set 7 V +2 CR +2 11/30/20, 08:09
-
Georg Ringer merged patch set 8 11/30/20, 09:58