Bug #85571
closedExtbase should return an empty ObjectStorage instead of null on empty relations
100%
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.
Updated by Alexander Schnitzler over 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