#105317TypeError: TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper::thawObjectProperty(): Return value must be of type ?object, array returned
Description
Steps to reproduce:
- Create an Extbase Model with a property of Type
TYPO3\CMS\Core\Resource\Folder. - Configure the property/column in TCA, see below example.
- Save record with empty value
- Map database record to model
Expected behaviour: null is assigned to property.
Actual behaviour: The TypeError is thrown.
Results of first debugging:
The extbase/Classes/Persistence/Generic/Mapper/ColumnMapFactory.php fails to properly set the type of relation in that scenario. I’d expect it to be Relation::HAS_ONE, but it is not set at all within: setRelations()
Example TCA:
'files_folder' => [
'exclude' => true,
'label' => 'LLL:EXT:events/Resources/Private/Language/locallang_csh_import.xlf:tx_events_domain_model_import.files_folder',
'description' => 'LLL:EXT:events/Resources/Private/Language/locallang_csh_import.xlf:tx_events_domain_model_import.files_folder.description',
'config' => [
'type' => 'folder',
'size' => 1,
'maxitems' => 1,
// No effect, code returns without taking this into account.
// 'relationship' => 'oneToOne',
],
],
Ideas:
- Always set explicitly configured
relationshipvalue first as default. - Set HAS_ONE properly in first condition of special folder handling.
- Let
FolderFieldTypeimplementRelationalFieldTypeInterface
Reviews 2
History 810
-
Daniel Siepmann changed description <span data-processor="relativetime" data-value="2024-10-16T06:00:52+00:00" > 10/16/24, 06:00 </span>
-
Daniel Siepmann changed description <span data-processor="relativetime" data-value="2024-10-16T06:01:12+00:00" > 10/16/24, 06:01 </span>
-
Daniel Siepmann changed description <span data-processor="relativetime" data-value="2024-10-16T06:04:06+00:00" > 10/16/24, 06:04 </span>
-
Oliver Bartsch commented <span data-processor="relativetime" data-value="2024-10-21T15:21:03+00:00" > 10/21/24, 15:21 </span>
-
Gerrit Code Review pushed patch set 1 for main to change 86682 status
NewUnder Review <span data-processor="relativetime" data-value="2024-10-21T16:23:37+00:00" > 10/21/24, 16:23 </span> -
Oliver Bartsch commented <span data-processor="relativetime" data-value="2024-10-21T16:25:02+00:00" > 10/21/24, 16:25 </span>
While I can’t reproduce the TypeError, you are right that no relation has been set in this case. I added this together with some test. Could you please check, whether this fixes the issue for you?
-
Gerrit Code Review pushed patch set 1 for 13.4 to change 86718 <span data-processor="relativetime" data-value="2024-10-23T17:15:23+00:00" > 10/23/24, 17:15 </span>
-
Oliver Bartsch commented and changed status
Under ReviewResolved done0 %100 % <span data-processor="relativetime" data-value="2024-10-23T17:25:08+00:00" > 10/23/24, 17:25 </span>Applied in changeset commit:a2e97ec7c13cfe48086a7dd18f557d08e10a0b60.
-
Daniel Siepmann commented <span data-processor="relativetime" data-value="2024-10-28T06:57:54+00:00" > 10/28/24, 06:57 </span>
I guess there is no easy “native” way, we do some workarounds: https://github.com/werkraum-media/events/blob/c8a17c6fa2dd0907b1bf00444b17693494ffe466/Classes/Domain/DestinationData/ImportFactory.php
We fetch the instance via the API and “register” it within Extbase. That way Extbase will use the instance while mapping through
TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper.I missed adding this to the description. Thanks for fixing already.
-
Benni Mack changed status
ResolvedClosed <span data-processor="relativetime" data-value="2025-12-02T14:32:51+00:00" > 12/02/25, 14:32 </span>
Hi Daniel, I fail to reproduce this with the steps you provided above. I always run into
No TCA schema exists for the name "tx_core_resource_folder".How exactly did you configure this property for mapping? – Or what exactly do you mean withMap database record to model? Do you do mapping manually or do you mean automatic mapping e.g. by fetching a record via the corresponding repository?