Project

General

Profile

Actions

Bug #103434

open

Extbase should check for property, not getter first

Added by Benni Mack about 2 months 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.

No data to display

Actions

Also available in: Atom PDF