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