Issue Bug New Orphaned

#103434Extbase should check for property, not getter first

Benni Mack 03/20/24, 11:19 updated 06/24/24, 14:10

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.

Reviews 0

No change resolves or names this issue in its commit message, and no comment links one.

Fix this issue

Start the commit message of your patch with this. Add what the patch does, and the versions it goes to in "Releases:". How to create a patch

Commit message
[BUGFIX] Extbase should check for property, not getter first Resolves: #103434 Releases: main