Project

General

Profile

Actions

Bug #105317

closed

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

Added by Daniel Siepmann about 1 month ago. Updated 21 days ago.

Status:
Resolved
Priority:
Should have
Assignee:
-
Category:
Extbase
Target version:
-
Start date:
2024-10-16
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
13
PHP Version:
Tags:
Complexity:
Is Regression:
Sprint Focus:

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
Actions #1

Updated by Daniel Siepmann about 1 month ago

  • Description updated (diff)
Actions #2

Updated by Daniel Siepmann about 1 month ago

  • Description updated (diff)
Actions #3

Updated by Daniel Siepmann about 1 month ago

  • Description updated (diff)
Actions #4

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?

Actions #5

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

Actions #6

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?

Actions #7

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

Actions #8

Updated by Oliver Bartsch 25 days ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
Actions #9

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.

Actions

Also available in: Atom PDF