Skip to content

Commit

Permalink
[BUGFIX] Do not try to parse non-strings as XML in DataHandler
Browse files Browse the repository at this point in the history
If the flexforms data is null, there is no point trying to parse
that as XML. This avoids type errors when `GeneralUtility` gets
native parameter type declarations for `GU::xml2array`, and it
should also slightly increase performance.

Also fix the corresponding PHPDoc type annotation to reflect
that a parameter in reality needs to be nullable.

Resolves: #101891
Releases: main, 12.4, 11.5
Change-Id: I39efc1d26300634c0bed74aee1f7ebd444acb8c0
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/81058
Tested-by: core-ci <typo3@b13.com>
Reviewed-by: Stefan Bürk <stefan@buerk.tech>
Tested-by: Stefan Bürk <stefan@buerk.tech>
  • Loading branch information
oliverklee authored and sbuerk committed Sep 18, 2023
1 parent 634d4ed commit e21e9b4
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions typo3/sysext/core/Classes/DataHandling/DataHandler.php
Expand Up @@ -4096,13 +4096,13 @@ public function insertNewCopyVersion($table, $fieldArray, $realPid)
* @param string $table Table name
* @param int $uid Record uid
* @param string $field Field name being processed
* @param string $value Input value to be processed.
* @param string|null $value Input value to be processed.
* @param array $row Record array
* @param array $conf TCA field configuration
* @param int $realDestPid Real page id (pid) the record is copied to
* @param int $language Language ID used in the duplicated record
* @param array $workspaceOptions Options to be forwarded if actions happen on a workspace currently
* @return array|string
* @return array|string|null
* @internal
* @see copyRecord()
*/
Expand All @@ -4127,12 +4127,12 @@ public function copyRecord_procBasedOnFieldType($table, $uid, $field, $value, $r
$row
);
$dataStructureArray = $flexFormTools->parseDataStructureByIdentifier($dataStructureIdentifier);
$currentValueArray = GeneralUtility::xml2array($value);
$currentValue = is_string($value) ? GeneralUtility::xml2array($value) : null;
// Traversing the XML structure, processing files:
if (is_array($currentValueArray)) {
$currentValueArray['data'] = $this->checkValue_flex_procInData($currentValueArray['data'], [], $dataStructureArray, [$table, $uid, $field, $realDestPid], 'copyRecord_flexFormCallBack', $workspaceOptions);
if (is_array($currentValue)) {
$currentValue['data'] = $this->checkValue_flex_procInData($currentValue['data'], [], $dataStructureArray, [$table, $uid, $field, $realDestPid], 'copyRecord_flexFormCallBack', $workspaceOptions);
// Setting value as an array! -> which means the input will be processed according to the 'flex' type when the new copy is created.
$value = $currentValueArray;
$value = $currentValue;
}
}
return $value;
Expand Down

0 comments on commit e21e9b4

Please sign in to comment.