Bug #65219

Property-Mapping: ObjectStorageConverter fails if a child object is converted to NULL

Added by Jost Baron almost 5 years ago. Updated over 2 years ago.

Status:
New
Priority:
Should have
Assignee:
-
Category:
Extbase
Target version:
-
Start date:
2015-02-22
Due date:
% Done:

0%

TYPO3 Version:
6.2
PHP Version:
5.5
Tags:
Complexity:
Is Regression:
No
Sprint Focus:

Description

Hi!

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 NULL values.

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.

History

#1 Updated by Jost Baron almost 5 years ago

This happens in 6.2.10rc1 as well as 6.2.9.

#2 Updated by Gerrit Code Review almost 5 years ago

  • Status changed from New to Under Review

Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/37651

#3 Updated by Gerrit Code Review almost 5 years ago

Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/37651

#4 Updated by Gerrit Code Review almost 5 years ago

Patch set 3 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/37651

#5 Updated by Gerrit Code Review over 4 years ago

Patch set 4 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/37651

#6 Updated by Teamgeist Medien over 4 years ago

This fix works for us. Thanks alot! (6.2.15)

#7 Updated by Gerrit Code Review over 4 years ago

Patch set 5 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/37651

#8 Updated by Riccardo De Contardi over 2 years ago

  • Status changed from Under Review to New

Also available in: Atom PDF