Skip to content

[BUGFIX] Fix array access on RecordInterface in ContentPreviewRenderer for TYPO3 v14#16

Merged
bmack merged 1 commit intomasterfrom
bugfix/v14-record-array-access
Apr 14, 2026
Merged

[BUGFIX] Fix array access on RecordInterface in ContentPreviewRenderer for TYPO3 v14#16
bmack merged 1 commit intomasterfrom
bugfix/v14-record-array-access

Conversation

@davidsteeb
Copy link
Copy Markdown
Contributor

Problem

In TYPO3 v14, GridColumnItem::getRecord() returns a RecordInterface object instead of an array. The ContentPreviewRenderer::renderPageModulePreviewContent() method used PHP array access syntax on the record:

if (trim($record['bodytext'] ?? '') !== '') {
    return $this->linkEditContent(nl2br(htmlentities($record['bodytext'])), $record) . '<br />';
}
  • The condition silently returned null (due to ??) but the inner expression $record['bodytext'] (without ??) would throw Cannot use object of type TYPO3\CMS\Core\Domain\Record as array if the condition ever evaluated to true.
  • Additionally, RecordInterface never implements ArrayAccess, making the ?? fallback behaviour version-dependent.

Fix

Detect whether the record is a RecordInterface (TYPO3 v14+) and use ->get() in that case, keeping the original array access path for TYPO3 v10–v13 compatibility. Note that linkEditContent() also had its signature updated in v14 to accept RecordInterface instead of array, so passing $record directly works correctly in all supported versions.

Compatibility

  • TYPO3 v10.4 / v11.5 / v12.x / v13.x: $record is an array → uses $record['bodytext'] path
  • TYPO3 v14.x: $record is a RecordInterface → uses $record->get('bodytext') path

…r for TYPO3 v14

In TYPO3 v14, GridColumnItem::getRecord() returns a RecordInterface object
instead of an array. The previous code used array access syntax ($record['bodytext'])
which throws "Cannot use object of type ... as array" when used without the null
coalescing operator.

Fix by detecting RecordInterface and using ->get() for v14+, keeping the original
array access path for TYPO3 v10–v13 compatibility.
@davidsteeb davidsteeb requested review from achimfritz and bmack April 14, 2026 10:30
@davidsteeb davidsteeb self-assigned this Apr 14, 2026
@bmack bmack merged commit 82b7a17 into master Apr 14, 2026
1 check passed
@bmack bmack deleted the bugfix/v14-record-array-access branch April 14, 2026 11:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants