Project

General

Profile

Actions

Bug #92473

closed

TYPO3\CMS\Core\Http\JsonReponse dont allow JsonSerializable and others

Added by Daniel Kern about 4 years ago. Updated 5 months ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Miscellaneous
Target version:
-
Start date:
2020-10-02
Due date:
% Done:

0%

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

Description

Issue:
I use TYPO3\CMS\Core\Http\JsonReponse in Middlewares. The constructor allow $data to be mixed. Even the internal function allows $data to be of any type. But between __construct and jsonEncode is another function setPayload wich only allows $data to be type of array. This results in the fact, that we can only respond arrays as JSON. But at least classes implementing @JsonSerializablev should be able to be responded too. Also, why isn't it possible to return other types as JSON too?

Solution:
Remove the type annotation of setPayload. There would be no harm, because jsonEncode already checks for conversion errors. This should also not break anything.

Before:
public function setPayload(array $data = [], $encodingOptions = self::DEFAULT_JSON_FLAGS): JsonResponse

After:
public function setPayload($data = [], $encodingOptions = self::DEFAULT_JSON_FLAGS): JsonResponse

Actions #1

Updated by Daniel Kern about 4 years ago

  • Subject changed from TYPO3\CMS\Core\Http\JsonReponse dont allow JsonSerializable to TYPO3\CMS\Core\Http\JsonReponse dont allow JsonSerializable and others
  • Complexity changed from easy to no-brainer
Actions #2

Updated by Gerrit Code Review about 4 years ago

  • Status changed from New to Under Review

Patch set 1 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/+/66016

Actions #3

Updated by Christian Kuhn about 3 years ago

  • Status changed from Under Review to New
Actions #4

Updated by Mathias Schreiber over 2 years ago

  • Sprint Focus set to Remote Sprint
Actions #5

Updated by Susanne Moog over 2 years ago

  • Complexity changed from no-brainer to medium
Actions #6

Updated by Benni Mack 5 months ago

  • Status changed from New to Closed

Closing this issue (see the corresponding review) as this is not the job of the JsonResponse.

Actions

Also available in: Atom PDF