Actions
Bug #85571
closedExtbase should return an empty ObjectStorage instead of null on empty relations
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