Bug #88829
closedBootstrap::handleRequest() throws type error, when controller action returns empty string
100%
Description
How to reproduce: Call an extbase controller action in frontend, which returns an empty string (not null!).
Exception:
Return value of TYPO3\CMS\Extbase\Core\Bootstrap::handleRequest() must be of the type string, null returned
Caused by return type hinting in:
https://github.com/TYPO3/TYPO3.CMS/blob/0c531014d09d0b16a92438c86d717a33e0a345b8/typo3/sysext/extbase/Classes/Core/Bootstrap.php#L188
Solution:
$content = (string) $response->shutdown();
Updated by Stephan Schuler over 5 years ago
When looking at the Response
class: That one seems invalid to me.
https://github.com/TYPO3/TYPO3.CMS/blob/0c531014d09d0b16a92438c86d717a33e0a345b8/typo3/sysext/extbase/Classes/Mvc/Response.php
According to annotations, Response::__toString()
, Response::shutdown()
and Response::getContent()
are meant to return strings.
The object is intialized as what looks invalid to me because you end up having those method not returning strings. Especially (new Result())->__toString()
doesn't return a string but null.
Instead of casting the result of Response::shutdown()
, I'd suggest to initlaize the Result::$content = '';
propert as an empty string. I don't know if that crashes elsewhere, but from the looks of the description of Response
, that feels as the right move here.
Updated by Alexander Schnitzler over 5 years ago
- Category set to Extbase
- Status changed from New to Accepted
- Assignee set to Alexander Schnitzler
- Target version set to next-patchlevel
Updated by Alexander Schnitzler over 5 years ago
Stephan Schuler wrote:
When looking at the
Response
class: That one seems invalid to me.
https://github.com/TYPO3/TYPO3.CMS/blob/0c531014d09d0b16a92438c86d717a33e0a345b8/typo3/sysext/extbase/Classes/Mvc/Response.phpAccording to annotations,
Response::__toString()
,Response::shutdown()
andResponse::getContent()
are meant to return strings.The object is intialized as what looks invalid to me because you end up having those method not returning strings. Especially
(new Result())->__toString()
doesn't return a string but null.Instead of casting the result of
Response::shutdown()
, I'd suggest to initlaize theResult::$content = '';
propert as an empty string. I don't know if that crashes elsewhere, but from the looks of the description ofResponse
, that feels as the right move here.
You describe the proper solution which I'd say is something for master and therefore for version 10.1.
In 10.0, we cannot trust the interface, therefore we should fulfil the contract of the return type of Bootstrap::handleRequest by casting the content to string.
Updated by Gerrit Code Review over 5 years ago
- Status changed from Accepted to Under Review
Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/61345
Updated by Gerrit Code Review over 5 years ago
Patch set 3 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/61345
Updated by Anonymous over 5 years ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset 33b0333cf05caccfd1c42ee19c52e57c266d5524.