Project

General

Profile

Actions

Bug #79426

closed

Method traverseFlexFormXMLData in TYPO3\CMS\Core\Configuration\FlexForm\FlexFormTools crashes with runtime error

Added by Thomas Hohn almost 8 years ago. Updated about 7 years ago.

Status:
Closed
Priority:
Should have
Assignee:
Category:
Code Cleanup
Target version:
Start date:
2017-01-23
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
8
PHP Version:
7.0
Tags:
Complexity:
Is Regression:
No
Sprint Focus:

Description

The following code will crash with an runtime-error if $dataStructureArray['sheets'] is not an array

// Traverse languages:
foreach ($dataStructureArray['sheets'] as $sheetKey => $sheetData) {
    // Render sheet:
    if (is_array($sheetData['ROOT']) && is_array($sheetData['ROOT']['el'])) {
        $PA['vKeys'] = ['DEF'];
        $PA['lKey'] = 'lDEF';
        $PA['callBackMethod_value'] = $callBackMethod_value;
        $PA['table'] = $table;
        $PA['field'] = $field;
        $PA['uid'] = $row['uid'];
        // Render flexform:
    $this->traverseFlexFormXMLData_recurse($sheetData['ROOT']['el'], $editData['data'][$sheetKey]['lDEF'], $PA, 'data/' . $sheetKey . '/lDEF');
    } else {
        return 'Data Structure ERROR: No ROOT element found for sheet "' . $sheetKey . '".';
    }
}

It would ne nicer to add a check if $dataStructureArray is not an array and then return an error string

// Check if $dataStructureArray['sheets'] is indeed an array before loop or it will crash with runtime error
if (!is_array($dataStructureArray['sheets'])) {
    return 'Data Structure ERROR: sheets is defined but not an array for table ' . $table . (isset($row['uid']) ? ' and uid ' . $row['uid'] : '');
}
Actions

Also available in: Atom PDF