Property-Mapping: ObjectStorageConverter fails if a child object is converted to NULL
A TypeConverter may return NULL, if the property it is asked to convert should not be converted. From the API documentation:
Actually convert from $source to $targetType, taking into account the fully built $convertedChildProperties and $configuration. The return value can be one of three types: * an arbitrary object, or a simple type (which has been created while mapping). This is the normal case. * NULL, indicating that this object should not be mapped (i.e. a "File Upload" Converter could return NULL if no file has been uploaded, and a silent failure should occur. * An instance of – This will be a user-visible error message later on. Furthermore, it should throw an Exception if an unexpected failure (like a security error) occurred or a configuration issue happened.
However, if a TypeConverter returns NULL, and it converted an object which is to be placed into an ObjectStorage, this Exception is thrown:
#1297759968: Exception while property mapping at property path "images":PHP Warning: spl_object_hash() expects parameter 1 to be object, null given in /home/jost/Projekte/Mein-Bauernhof/t3cores/typo3_src-6.2.10rc1/typo3/sysext/extbase/Classes/Persistence/ObjectStorage.php line 147
This is caused by the
attach()-method of an object storage, which can not handle
I'm not sure how to fix this. I see two ways: Making sure that
NULL-values are already filtered out of the
$convertedChildProperties parameter for TypeConverters, or adding a check for
NULL in the ObjectStorageTypeConverter.