Bug #103434
openExtbase should check for property, not getter first
0%
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.
Updated by David Bruchmann 5 months 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}
Updated by David Bruchmann 5 months ago
- Related to Task #100136: ObjectConverter should infer property types from properties, not from setters added