Skip to content

Commit 41a2775

Browse files
georgringerlolli42
authored andcommitted
[BUGFIX] Rework Flexform data handling in TcaFlexPrepare
The previous code in `TcaFlexPrepare->initializeDataValues()` was pretty optimistic regarding the incoming data and may booted XML parsing on empty strings and did not consider `null` values. The code is changed to check now whether the incoming data is not null and not an empty string before using it at all. Resolves: #104962 Releases: main, 13.4 Change-Id: If8dbffdc82b1a1e53409e0417d5ddd7a25ed6946 Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/87684 Reviewed-by: Andreas Kienast <akienast@scripting-base.de> Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch> Reviewed-by: Georg Ringer <georg.ringer@gmail.com> Tested-by: Christian Kuhn <lolli@schwarzbu.ch> Tested-by: Georg Ringer <georg.ringer@gmail.com> Tested-by: Andreas Kienast <akienast@scripting-base.de> Tested-by: core-ci <typo3@b13.com>
1 parent 7b7bc70 commit 41a2775

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

typo3/sysext/backend/Classes/Form/FormDataProvider/TcaFlexPrepare.php

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -93,18 +93,17 @@ protected function initializeDataStructure(array $result, string $fieldName): ar
9393
*/
9494
protected function initializeDataValues(array $result, string $fieldName): array
9595
{
96-
if (!array_key_exists($fieldName, $result['databaseRow'])) {
97-
$result['databaseRow'][$fieldName] = '';
98-
}
9996
$valueArray = [];
100-
if (isset($result['databaseRow'][$fieldName])) {
101-
$valueArray = $result['databaseRow'][$fieldName];
102-
}
103-
if (!is_array($result['databaseRow'][$fieldName])) {
104-
$valueArray = GeneralUtility::xml2array($result['databaseRow'][$fieldName]);
105-
}
106-
if (!is_array($valueArray)) {
107-
$valueArray = [];
97+
98+
if (isset($result['databaseRow'][$fieldName]) && $result['databaseRow'][$fieldName] !== '') {
99+
if (is_array($result['databaseRow'][$fieldName])) {
100+
$valueArray = $result['databaseRow'][$fieldName];
101+
} else {
102+
$valueArray = GeneralUtility::xml2array($result['databaseRow'][$fieldName]);
103+
if (!is_array($valueArray)) {
104+
$valueArray = [];
105+
}
106+
}
108107
}
109108
if (!isset($valueArray['data'])) {
110109
$valueArray['data'] = [];

0 commit comments

Comments
 (0)