Project

General

Profile

Actions

Bug #104793

closed

Fatal error when overwriting defaultViewObjectName

Added by Benjamin Franzke 3 months ago. Updated about 1 month ago.

Status:
Closed
Priority:
Must have
Category:
Extbase
Target version:
-
Start date:
2024-09-02
Due date:
% Done:

0%

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

Description

Only happens in current-main (since https://github.com/TYPO3/typo3/commit/c22b72cde6838f4a080a22bde25b9f3632337169).

Fatal error: Type of MyNamespace\Controller\MyController::$defaultViewObjectName must be ?string (as in class TYPO3\CMS\Extbase\Mvc\Controller\ActionController)

This error happens since https://review.typo3.org/c/Packages/TYPO3.CMS/+/85735/ changed string to ?string in https://review.typo3.org/c/Packages/TYPO3.CMS/+/85735/60/typo3/sysext/extbase/Classes/Mvc/Controller/ActionController.php#97.


Related issues 3 (0 open3 closed)

Related to TYPO3 Core - Feature #104773: Implement and use a core ViewFactoryInterfaceClosed2024-08-29

Actions
Related to TYPO3 Core - Task #102632: Use strict types in extbase ActionControllerClosedTorben Hansen2023-12-08

Actions
Related to TYPO3 Core - Task #104770: Do not declare extbase defaultViewObjectName, set itClosed2024-08-29

Actions
Actions #1

Updated by Oliver Hader 3 months ago

  • Related to Feature #104773: Implement and use a core ViewFactoryInterface added
Actions #2

Updated by Christian Kuhn 2 months ago

  • Related to Task #102632: Use strict types in extbase ActionController added
Actions #3

Updated by Christian Kuhn 2 months ago

  • Related to Task #104770: Do not declare extbase defaultViewObjectName, set it added
Actions #4

Updated by Christian Kuhn 2 months ago ยท Edited

  • Status changed from Accepted to Resolved

The property has been changed with #102632 in v13 once already, the patch only changed it a second time.

In general, when abstracts delivered by core monorepo contain properties, extensions should set values in __construct() if they need to change values.

This has been documented with https://review.typo3.org/c/Packages/TYPO3.CMS/+/81885/10/typo3/sysext/core/Documentation/Changelog/13.0/Breaking-102632-UseStrictTypesInExtbaseActionController.rst

This is what pre-patch #104770 did, now following this advise to be a good example.

Since the property type has been changed in v13, giving extensions a chance adopting to this by setting the value in __construct(), and the type has now been "just" changed a second time, I do not consider this breaking as it has been marked breaking in 13.0 including a proper upgrade path already.

As such, I tend to keep the property type as is.

Actions #5

Updated by Christian Kuhn 2 months ago

Note we should probably communicate this more clearly: When core delivers some abstract with properties, extensions should in general set values of such properties in __construct().
This is the only way to give core freedom to add or change types without triggering liskov contra/co-variant violations.
I'll add a mental note to add something to typo3 explained cgl / best practice section docs.

Actions #6

Updated by Benni Mack about 1 month ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF