Project

General

Profile

Actions

Bug #88829

closed

Bootstrap::handleRequest() throws type error, when controller action returns empty string

Added by Armin Vieweg almost 5 years ago. Updated over 4 years ago.

Status:
Closed
Priority:
Should have
Category:
Extbase
Target version:
Start date:
2019-07-23
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
10
PHP Version:
Tags:
Complexity:
Is Regression:
Sprint Focus:

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();
Actions #1

Updated by Stephan Schuler almost 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.

Actions #2

Updated by Alexander Schnitzler almost 5 years ago

  • Category set to Extbase
  • Status changed from New to Accepted
  • Assignee set to Alexander Schnitzler
  • Target version set to next-patchlevel
Actions #3

Updated by Alexander Schnitzler almost 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.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.

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.

Actions #4

Updated by Gerrit Code Review over 4 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

Actions #5

Updated by Gerrit Code Review over 4 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

Actions #6

Updated by Anonymous over 4 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
Actions #7

Updated by Benni Mack over 4 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF