From b6378d2fbd384a9689c05951e7a7d3692175d95b Mon Sep 17 00:00:00 2001 From: Oliver Bartsch Date: Tue, 18 Apr 2023 11:05:26 +0200 Subject: [PATCH] [BUGFIX] Prevent type errors in ExportController In case an export is created based on e.g. an invalid preset, no PHP TypeError should occur. This is now fixed by properly typecasting the input data. Additionally, two possible undefined array key access warnings are fixed. Resolves: #97403 Releases: main, 11.5 Change-Id: I994391909b44247879099ce92d61911c56ca7e39 Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/78732 Reviewed-by: Oliver Klee Reviewed-by: Benni Mack Tested-by: Benni Mack Tested-by: core-ci --- typo3/sysext/impexp/Classes/Controller/ExportController.php | 2 +- typo3/sysext/impexp/Classes/Import.php | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/typo3/sysext/impexp/Classes/Controller/ExportController.php b/typo3/sysext/impexp/Classes/Controller/ExportController.php index d12c8377466d..0a679f66096e 100644 --- a/typo3/sysext/impexp/Classes/Controller/ExportController.php +++ b/typo3/sysext/impexp/Classes/Controller/ExportController.php @@ -240,7 +240,7 @@ protected function exportData(array $inData): array if (!empty($inData['filetype'])) { $this->export->setExportFileType((string)$inData['filetype']); } - $this->export->setExportFileName($inData['filename'] ?? ''); + $this->export->setExportFileName((string)($inData['filename'] ?? '')); // Static tables: if (is_array($inData['external_static']['tables'] ?? null)) { diff --git a/typo3/sysext/impexp/Classes/Import.php b/typo3/sysext/impexp/Classes/Import.php index f484a9e2a8f8..5435bf47133a 100644 --- a/typo3/sysext/impexp/Classes/Import.php +++ b/typo3/sysext/impexp/Classes/Import.php @@ -1049,7 +1049,9 @@ protected function addSingle(array &$importData, string $table, int $uid, $pid): // @see fixUidLocalInSysFileReferenceRecords() // If it's empty or a uid to another record the FileExtensionFilter will throw an exception or // delete the reference record if the file extension of the related record doesn't match. - if (!($table === 'sys_file_reference' && $field === 'uid_local')) { + if (!($table === 'sys_file_reference' && $field === 'uid_local') + && is_array($GLOBALS['TCA'][$table]['columns'][$field]['config'] ?? false) + ) { $importData[$table][$ID][$field] = $this->getReferenceDefaultValue($GLOBALS['TCA'][$table]['columns'][$field]['config']); } break; @@ -1459,7 +1461,7 @@ protected function processSoftReferences(): void if (isset($GLOBALS['TCA'][$table])) { foreach ($records as $uid => $record) { if (is_array($record['softrefs'] ?? null)) { - $actualUid = BackendUtility::wsMapId($table, $this->importMapId[$table][$uid]); + $actualUid = BackendUtility::wsMapId($table, $this->importMapId[$table][$uid] ?? 0); // First, group soft references by record field ... // (this could probably also have been done with $this->dat['records'] instead of $this->dat['header']) $softrefs = [];