Skip to content

Commit 148c67a

Browse files
committed
[BUGFIX] Fix array access on RecordInterface in ContentPreviewRenderer 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.
1 parent 00925d9 commit 148c67a

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

Classes/Backend/Preview/ContentPreviewRenderer.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,18 @@
1313
*/
1414

1515
use TYPO3\CMS\Backend\View\BackendLayout\Grid\GridColumnItem;
16+
use TYPO3\CMS\Core\Domain\RecordInterface;
1617

1718
class ContentPreviewRenderer extends \TYPO3\CMS\Backend\Preview\StandardContentPreviewRenderer
1819
{
1920
public function renderPageModulePreviewContent(GridColumnItem $item): string
2021
{
2122
$record = $item->getRecord();
22-
if (trim($record['bodytext'] ?? '') !== '') {
23-
return $this->linkEditContent(nl2br(htmlentities($record['bodytext'])), $record) . '<br />';
23+
$bodytext = $record instanceof RecordInterface
24+
? (string)($record->get('bodytext') ?? '')
25+
: (string)($record['bodytext'] ?? '');
26+
if (trim($bodytext) !== '') {
27+
return $this->linkEditContent(nl2br(htmlentities($bodytext)), $record) . '<br />';
2428
}
2529
return parent::renderPageModulePreviewContent($item);
2630
}

0 commit comments

Comments
 (0)