Project

General

Profile

Actions

Bug #95819

closed

Extbase does not support uninitialized domain object properties

Added by Alexander Schnitzler over 2 years ago. Updated 11 months ago.

Status:
Closed
Priority:
Should have
Category:
Extbase
Target version:
-
Start date:
2021-10-30
Due date:
% Done:

100%

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

Description

As of PHP 7.4, object properties can be defined with a property type and without a default value. This means, the property is uninitialized and needs to be initialized (a value must be set) before it can be accessed.

Example:

class Foo {

    protected string $string;
    protected ObjectStorage $items;

    public function __construct(string $string)
    {
        $this->string = $string;
        $this->items = new ObjectStorage();
    }

}

This is perfectly valid php code but as Extbase does not support detecting those properties, they are neither respected when saving an object to the database nor when reconstituting an object from a database row. Such properties then remain uninitialized and lead to fatal errors.

This is especially annoying when there is a desire to not set a default value like for ObjectStorages which have to be initialized with null although that is no desired state in any case:

class Foo {

    protected string $string;
    protected ?ObjectStorage $items = null;

    public function __construct(string $string)
    {
        $this->string = $string;
        $this->items = new ObjectStorage();
    }

}

To mitigate that issue, Extbase needs to rely on Reflection instead of method get_object_vars();


Related issues 3 (0 open3 closed)

Related to TYPO3 Core - Bug #98148: Extbase persistence erronously tries to persist unmapped private property Closed2022-08-16

Actions
Related to TYPO3 Core - Bug #102278: Missing default value for property Container.php:$prototypeObjectsWhichAreCurrentlyInstanciated will lead to #1546632293 RuntimeException in GenericObjectValidator.phpResolved2023-10-27

Actions
Has duplicate TYPO3 Core - Bug #97646: Extbase property mapper does not work with uninitialized propertiesClosedSascha Egerer2022-05-17

Actions
Actions

Also available in: Atom PDF