X-Git-Url: http://git.typo3.org/Packages/TYPO3.CMS.git/blobdiff_plain/4a84ac7c89afd9c186c84a939a797856d8705263..f8022ed4b101c257fb7c98b267d27dfccd251344:/typo3/sysext/impexp/Classes/Import.php diff --git a/typo3/sysext/impexp/Classes/Import.php b/typo3/sysext/impexp/Classes/Import.php index 48b18a880e89..f5b9753d8914 100644 --- a/typo3/sysext/impexp/Classes/Import.php +++ b/typo3/sysext/impexp/Classes/Import.php @@ -515,6 +515,34 @@ class Import extends ImportExport // unset the sys_file records to prevent an import in writeRecords_records unset($this->dat['header']['records']['sys_file']); + // remove all sys_file_reference records that point to file records which are unknown + // in the system to prevent exceptions + $this->removeSysFileReferenceRecordsFromImportDataWithRelationToMissingFile(); + } + + /** + * Removes all sys_file_reference records from the import data array that are pointing to sys_file records which + * are missing not in the import data to prevent exceptions on checking the related file started by the Datahandler. + * + * @return void + */ + protected function removeSysFileReferenceRecordsFromImportDataWithRelationToMissingFile() + { + if (!isset($this->dat['header']['records']['sys_file_reference'])) { + return; + } + + foreach ($this->dat['header']['records']['sys_file_reference'] as $sysFileReferenceUid => $_) { + $fileReferenceRecord = $this->dat['records']['sys_file_reference:' . $sysFileReferenceUid]['data']; + if (!in_array($fileReferenceRecord['uid_local'], $this->import_mapId['sys_file'])) { + unset($this->dat['header']['records']['sys_file_reference'][$sysFileReferenceUid]); + unset($this->dat['records']['sys_file_reference:' . $sysFileReferenceUid]); + $this->error('Error: sys_file_reference record ' . (int)$sysFileReferenceUid + . ' with relation to sys_file record ' . (int)$fileReferenceRecord['uid_local'] + . ', which is not part of the import data, was not imported.' + ); + } + } } /**