Issue Bug Resolved

#110439f:render.text: TypeError in getRecordType() for Extbase models mapped to tables without ctrl['type']

Stefan Maischner 08/11/26, 13:02 updated 08/12/26, 09:05

Description

The new `<f:render>` ViewHelper (introduced in #108868, TYPO3 14.2) throws a<br>TypeError when used with an Extbase model that is mapped to a table without a<br>record type field (`ctrl[‘type’]`) in TCA, e.g. `sys_category`:</f:render>

TypeError: TYPO3\CMS\Fluid\ViewHelpers\Render\TextViewHelper::getRecordType():
Return value must be of type ?string, int returned

Reproduce:

1. TYPO3 14.2, EXT:news (or any Extbase model mapped to sys_category or another
table without ctrl[‘type’])
2. Render in a Fluid template:

<f:render.text record=”{category}” field=“title” />
where {category} is e.g. GeorgRinger\News\Domain\Model\Category
3. TypeError is thrown.

Analysis:

In TextViewHelper::getRecordType():

$recordTypeFieldName = $dataMap->getRecordTypeColumnName();
foreach ($input->_getProperties() as $propertyName => $value) {
if ($dataMap->getColumnMap($propertyName)?->getColumnName() === $recordTypeFieldName) {
return $value;
}
}

For tables without ctrl[‘type’], getRecordTypeColumnName() returns null.
For any model property that has no ColumnMap (e.g. a property not backed by a
TCA column), the nullsafe chain `getColumnMap($propertyName)?->getColumnName()`
also evaluates to null, so `null === null` matches and the value of that
unrelated property is returned. If that value is an int (in the news Category
model this is the case), the declared return type `?string` is violated and a
TypeError is thrown. With a string property it would silently return a wrong
record type instead.

Suggested fix:

Return early when the table has no record type field:

$recordTypeFieldName = $dataMap->getRecordTypeColumnName();
if ($recordTypeFieldName === null) {
return null;
}

Additionally, the loop should skip properties without a ColumnMap to avoid
false positives, and the matched value should be cast to string.

Expected behaviour:

Extbase models of tables without a record type field should work; ‘fullType’
should simply be the table name (the calling code in extractInformation()
already handles $recordType being null/empty).

Reviews 1