Project

General

Profile

Actions

Bug #65219

closed

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

Added by Jost Baron almost 10 years ago. Updated over 1 year ago.

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

0%

Estimated time:
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.

Actions #1

Updated by Jost Baron almost 10 years ago

This happens in 6.2.10rc1 as well as 6.2.9.

Actions #2

Updated by Gerrit Code Review over 9 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

Actions #3

Updated by Gerrit Code Review over 9 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

Actions #4

Updated by Gerrit Code Review over 9 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

Actions #5

Updated by Gerrit Code Review about 9 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

Actions #6

Updated by Teamgeist Medien about 9 years ago

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

Actions #7

Updated by Gerrit Code Review about 9 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

Actions #8

Updated by Riccardo De Contardi over 7 years ago

  • Status changed from Under Review to New
Actions #9

Updated by Stefan Froemken over 1 year ago

  • Status changed from New to Closed

Hello,

thank you for reporting this issue. The PropertyMapper will first call the PersistenceObjectConverter for each individual entry. If it is an array, it will be handled as a new object without UID. If it is string or int, it expects an existing record which will be mapped to an object. Only in cases where the value is an empty string or 0, it will return NULL.
As we are speaking of the PropertyMapper, it tries to map a request from a form. So IMO the problem exists in the form itself. Maybe you add further child records with JavaScript. Maybe you have forgotten to set __identifier in one of your child values.

I will close the ticket now. If you feel this is the wrong decision, let me know, and I will re-open it.

Please send us further information about your form. Maybe it would help, if you send us also an example of the POST request (array).

Stefan

Actions

Also available in: Atom PDF