Skip to content

Commit

Permalink
[BUGFIX] Prevent type errors in ExportController
Browse files Browse the repository at this point in the history
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 <typo3-coding@oliverklee.de>
Reviewed-by: Benni Mack <benni@typo3.org>
Tested-by: Benni Mack <benni@typo3.org>
Tested-by: core-ci <typo3@b13.com>
  • Loading branch information
o-ba authored and bmack committed Apr 18, 2023
1 parent b10285e commit b6378d2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Expand Up @@ -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)) {
Expand Down
6 changes: 4 additions & 2 deletions typo3/sysext/impexp/Classes/Import.php
Expand Up @@ -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;
Expand Down Expand Up @@ -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 = [];
Expand Down

0 comments on commit b6378d2

Please sign in to comment.