[BUGFIX] impexp: Wrong FAL references after import 68/55368/2
authorChristian Kuhn <lolli@schwarzbu.ch>
Mon, 15 Jan 2018 14:54:57 +0000 (15:54 +0100)
committerChristian Kuhn <lolli@schwarzbu.ch>
Mon, 15 Jan 2018 19:51:10 +0000 (20:51 +0100)
Fix a case during ext:impexp FAL uid mapping where
sys_file_reference end up pointing to wrong sys_file
records in case new sys_file uids also already exist
in import file, due to multiple mappings.
Power the patch with a functional test - it fails
without the change in Import.php and is ok with the
change.
See the test method comments for more details
on what exactly is checked here.

Change-Id: I472cad2652e8d6f5d30e4ebc68ff1ae93de71ea1
Resolves: #67188
Releases: master, 8.7, 7.6
Reviewed-on: https://review.typo3.org/55368
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/impexp/Classes/Import.php

index 172db45..bcd3c6e 100644 (file)
@@ -580,10 +580,11 @@ class Import extends ImportExport
         }
 
         foreach ($this->dat['header']['records']['sys_file_reference'] as $sysFileReferenceUid => $_) {
-            $fileReferenceRecord = $this->dat['records']['sys_file_reference:' . $sysFileReferenceUid]['data'];
-            if ($fileReferenceRecord['uid_local'] == $oldFileUid) {
-                $fileReferenceRecord['uid_local'] = $newFileUid;
-                $this->dat['records']['sys_file_reference:' . $sysFileReferenceUid]['data'] = $fileReferenceRecord;
+            if (!isset($this->dat['records']['sys_file_reference:' . $sysFileReferenceUid]['hasBeenMapped'])
+                && $this->dat['records']['sys_file_reference:' . $sysFileReferenceUid]['data']['uid_local'] == $oldFileUid
+            ) {
+                $this->dat['records']['sys_file_reference:' . $sysFileReferenceUid]['hasBeenMapped'] = true;
+                $this->dat['records']['sys_file_reference:' . $sysFileReferenceUid]['data']['uid_local'] = $newFileUid;
             }
         }
     }