+ // 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.'
+ );
+ }
+ }