Skip to content
Snippets Groups Projects
Commit 1a88644b authored by Christoph Lehmann's avatar Christoph Lehmann Committed by Georg Ringer
Browse files

[BUGFIX] Prevent rendering FlexForm diff of deleted records in history

When the record does not exist anymore, then the FlexForm definition
might also not exist anymore (imagine a removed plugin) and it results
in an Exception.

Resolves: #102656
Releases: main, 12.4
Change-Id: I3eac287a50366ae8ca66416080738634eb65ae97
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/84643


Tested-by: default avatarGeorg Ringer <georg.ringer@gmail.com>
Reviewed-by: default avatarGeorg Ringer <georg.ringer@gmail.com>
Reviewed-by: default avatarStefan Bürk <stefan@buerk.tech>
Tested-by: default avatarcore-ci <typo3@b13.com>
Tested-by: default avatarStefan Bürk <stefan@buerk.tech>
parent ed7f90d8
Branches
Tags
No related merge requests found
......@@ -45,7 +45,11 @@ class FlexFormValueFormatter
return '';
}
$record = BackendUtility::getRecord($tableName, $uid) ?? [];
$record = BackendUtility::getRecord($tableName, $uid);
if (is_null($record)) {
// Record is already deleted
return '';
}
// Get FlexForm data and structure
$flexFormDataArray = GeneralUtility::xml2array($value);
......
......@@ -20,6 +20,8 @@ namespace TYPO3\CMS\Backend\Tests\Functional\View\ValueFormatter;
use PHPUnit\Framework\Attributes\Test;
use TYPO3\CMS\Backend\View\ValueFormatter\FlexFormValueFormatter;
use TYPO3\CMS\Core\Core\Bootstrap;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
final class FlexFormValueFormatterTest extends FunctionalTestCase
......@@ -35,16 +37,19 @@ final class FlexFormValueFormatterTest extends FunctionalTestCase
#[Test]
public function flexFormDataWillBeDisplayedHumanReadable(): void
{
$GLOBALS['TCA']['aTableName']['columns']['aFieldName']['config'] = $this->getFieldTcaConfig();
$GLOBALS['TCA']['tt_content']['columns']['pi_flexform']['config'] = $this->getFieldTcaConfig();
$expectedOutput = trim(file_get_contents(__DIR__ . '/Fixtures/FlexFormValueFormatter/ValuePreview.txt'));
$flexFormData = file_get_contents(__DIR__ . '/Fixtures/FlexFormValueFormatter/FlexFormValue.xml');
$connection = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable('tt_content');
$connection->insert('tt_content', ['pi_flexform' => $flexFormData]);
$flexFormValueFormatter = new FlexFormValueFormatter();
$actualOutput = $flexFormValueFormatter->format(
'aTableName',
'aFieldName',
'tt_content',
'pi_flexform',
$flexFormData,
0,
(int)$connection->lastInsertId('tt_content'),
$this->getFieldTcaConfig(),
);
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment