Bug #105317
closedTypeError: TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper::thawObjectProperty(): Return value must be of type ?object, array returned
100%
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
relationship
value first as default. - Set HAS_ONE properly in first condition of special folder handling.
- Let
FolderFieldType
implementRelationalFieldTypeInterface
Updated by Oliver Bartsch 27 days ago ยท Edited
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 with Map 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?
Updated by Gerrit Code Review 27 days ago
- Status changed from New to Under Review
Patch set 1 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/86682
Updated by Oliver Bartsch 27 days ago
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?
Updated by Gerrit Code Review 25 days ago
Patch set 1 for branch 13.4 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/86718
Updated by Oliver Bartsch 25 days ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset a2e97ec7c13cfe48086a7dd18f557d08e10a0b60.
Updated by Daniel Siepmann 21 days ago
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.