Project

General

Profile

Actions

Bug #103434

open

Extbase should check for property, not getter first

Added by Benni Mack 3 months ago. Updated 6 days ago.

Status:
New
Priority:
Should have
Assignee:
-
Category:
Extbase
Target version:
-
Start date:
2024-03-20
Due date:
% Done:

0%

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

Description

I have this custom code in my Extbase model:

class News extends AbstractEntity
{
    protected string $authors = '';
    protected string $subsidiaries = '';
...
    public function getSubsidiaries(): array
    {
        return GeneralUtility::trimExplode(',', $this->subsidiaries);
    }

In TCA, this is a field of type select / selectMultipleSideBySide.

Extbase / Symfony PropertyInfo is detecting the field as array, even though the property is a string, due to the getter method, and cannot handle an array yet:
https://github.com/TYPO3/typo3/blob/0e1b095b51edd20e10f05edbec630e0a57074c08/typo3/sysext/extbase/Classes/Persistence/Generic/Mapper/DataMapper.php#L251C17-L251C23

For this reason, the property will never get mapped.

If I create a getter "getAvailableSubsidiaries(): array" and remove the original mapper, the type will be detected as string and then populated in DataMapper.

I think the property should take precedence over the getter.


Related issues 1 (1 open0 closed)

Related to TYPO3 Core - Task #100136: ObjectConverter should infer property types from properties, not from settersNewAlexander Schnitzler2023-03-10

Actions
Actions #1

Updated by David Bruchmann 6 days ago

There is a resembling comment in https://github.com/TYPO3/typo3/blob/main/typo3/sysext/extbase/Classes/Property/TypeConverter/ObjectConverter.php#L93-L94

        // @todo: infer property type from property instead of from setter and make setter optional
        //        {@link https://forge.typo3.org/issues/100136}
Actions #2

Updated by David Bruchmann 6 days ago

  • Related to Task #100136: ObjectConverter should infer property types from properties, not from setters added
Actions

Also available in: Atom PDF