Issue Bug Closed

#105317TypeError: TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper::thawObjectProperty(): Return value must be of type ?object, array returned

Daniel Siepmann 10/16/24, 05:59 updated 12/02/25, 14:32

Description

Steps to reproduce:

  1. Create an Extbase Model with a property of Type TYPO3\CMS\Core\Resource\Folder.
  2. Configure the property/column in TCA, see below example.
  3. Save record with empty value
  4. 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:
  1. Always set explicitly configured relationship value first as default.
  2. Set HAS_ONE properly in first condition of special folder handling.
  3. Let FolderFieldType implement RelationalFieldTypeInterface

Reviews 2

History 810

  1. Oliver Bartsch commented <span data-processor="relativetime" data-value="2024-10-21T15:21:03+00:00" > 10/21/24, 15:21 </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 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?

  2. 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?

  3. Oliver Bartsch commented and changed status Under Review Resolved done 0 % 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.

  4. 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.