Issue Bug Closed

#104668RuntimeException in history module for deleted record with FlexForm

Daniel Siepmann 08/20/24, 08:52 updated 08/20/24, 09:02

Description

Not sure about older versions, we currently have the issue in 12.4.16.

Steps to reproduce:

  1. Create a tt_content element with a pi_flexform
  2. Change something within the FlexForm of the element
  3. Delete the element
  4. Open history of the page with the element

The following exception will be shown:

(1/1) #1463578899 RuntimeException

TCA misconfiguration in table "tt_content" field "pi_flexform" config section: ds_pointerField "list_type" points to a field name that does not exist.
in /vendor/typo3/cms-core/Classes/Configuration/FlexForm/FlexFormTools.php line 482

            // ds_pointerField to some field name should take care that field does exist, too. They are a pair,
            // so there shouldn't be a situation where the field does not exist. Throw an exception if that is violated.
            if (!isset($row[$pointerFieldArray[0]])) {
                // If it's declared, it must exist -> not catchable
                throw new \RuntimeException(
                    'TCA misconfiguration in table "' . $tableName . '" field "' . $fieldName . '" config section:'
                    . ' ds_pointerField "' . $pointerFieldArray[0] . '" points to a field name that does not exist.',
                    1463578899
                );

at TYPO3\CMS\Core\Configuration\FlexForm\FlexFormTools->getDataStructureIdentifierFromTcaArray()
in /vendor/typo3/cms-core/Classes/Configuration/FlexForm/FlexFormTools.php line 205

                $fieldName,
                $row
            );
        } elseif (is_array($tcaDataStructureArray)) {
            $dataStructureIdentifier = $this->getDataStructureIdentifierFromTcaArray(
                $fieldTca,
                $tableName,
                $fieldName,
                $row

at TYPO3\CMS\Core\Configuration\FlexForm\FlexFormTools->getDefaultIdentifier()
in /vendor/typo3/cms-core/Classes/Configuration/FlexForm/FlexFormTools.php line 175

    public function getDataStructureIdentifier(array $fieldTca, string $tableName, string $fieldName, array $row): string
    {
        $dataStructureIdentifier = $this->eventDispatcher
            ->dispatch(new BeforeFlexFormDataStructureIdentifierInitializedEvent($fieldTca, $tableName, $fieldName, $row))
            ->getIdentifier() ?? $this->getDefaultIdentifier($fieldTca, $tableName, $fieldName, $row);

        $dataStructureIdentifier = $this->eventDispatcher
            ->dispatch(new AfterFlexFormDataStructureIdentifierInitializedEvent($fieldTca, $tableName, $fieldName, $row, $dataStructureIdentifier))
            ->getIdentifier();

at TYPO3\CMS\Core\Configuration\FlexForm\FlexFormTools->getDataStructureIdentifier()
in /vendor/typo3/cms-backend/Classes/View/ValueFormatter/FlexFormValueFormatter.php line 81

        array $record
    ): array {
        $conf['config'] = $tcaConfiguration;
        $flexFormTools = GeneralUtility::makeInstance(FlexFormTools::class);
        $flexFormIdentifier = $flexFormTools->getDataStructureIdentifier($conf, $tableName, $fieldName, $record);
        return $flexFormTools->parseDataStructureByIdentifier($flexFormIdentifier);
    }

    /**

at TYPO3\CMS\Backend\View\ValueFormatter\FlexFormValueFormatter->getFlexFormDataStructure()
in /vendor/typo3/cms-backend/Classes/View/ValueFormatter/FlexFormValueFormatter.php line 56

        $record = BackendUtility::getRecord($tableName, $uid) ?? [];

        // Get FlexForm data and structure
        $flexFormDataArray = GeneralUtility::xml2array($value);
        $flexFormDataStructure = $this->getFlexFormDataStructure($fieldConfiguration, $tableName, $fieldName, $record);

        // Map data to FlexForm structure and build an easy to handle array
        $processedSheets = $this->getProcessedSheets($flexFormDataStructure, $flexFormDataArray['data']);

The issue seems to be within FlexFormValueFormatter which fetches the record but only if it is not deleted. It than passes the record down the stack until a validation will check the pointer field which doesn’t exist in the empty record array due to being a deleted record.

Reviews 1