Project

General

Profile

Actions

Bug #85571

closed

Extbase should return an empty ObjectStorage instead of null on empty relations

Added by Stefan P almost 6 years ago. Updated about 4 years ago.

Status:
Rejected
Priority:
-- undefined --
Assignee:
-
Category:
Extbase
Target version:
-
Start date:
2018-07-16
Due date:
% Done:

100%

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

Description

Mapping non-scalar properties to null is OK for single relations (to own models or \DateTime, for example) - if it's not there it is null by definition.

But properties that are mapped to an ObjectStorage should never be null, they should be an empty ObjectStorage instead if there's no relation. This would prevent such bugs: #85172 - especially in large projects it's hard to track whether all ObjectStorages in all models are initialized correctly.

To be explicit, I expect the following to be always an ObjectStorage (which can itself have a count of 0, be empty, of course) after Extbase is done with the mapping:

/**
 * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\My\Related\Class>
 */
protected $relatedObjects;

Currently Extbase maps this to null, when there are no items in the relation.
Actions #1

Updated by Alexander Schnitzler about 4 years ago

  • Status changed from New to Rejected
  • Priority changed from Should have to -- undefined --
  • % Done changed from 0 to 100

Extbase will not be changed in this regard meaning that it will not initialise properties for you.
Please take care of initialising your model properties as shown in this patch: https://github.com/TYPO3/TYPO3.CMS/commit/d8bd7129136b816fb5150843127a42d706063319

Actions

Also available in: Atom PDF