[BUGFIX] Don't ignore file imports in fallback storage 47/30147/4
authorMarc Bastian Heinrichs <typo3@mbh-software.de>
Thu, 15 May 2014 16:22:44 +0000 (18:22 +0200)
committerMarkus Klein <klein.t3@mfc-linz.at>
Fri, 20 Jun 2014 21:03:20 +0000 (23:03 +0200)
An export could contain sys_file records that are "stored" in the
fallback storage (ID 0). They must not be ignored.

Resolves: #58841
Releases: 6.3, 6.2
Change-Id: I39855810621310831ab1353c5e56f4529a7ac3aa
Reviewed-on: https://review.typo3.org/30147
Reviewed-by: Wouter Wolters
Tested-by: Wouter Wolters
Reviewed-by: Markus Klein
Tested-by: Markus Klein
typo3/sysext/impexp/Classes/ImportExport.php

index e248e89..4f4e7f1 100644 (file)
@@ -1629,7 +1629,7 @@ class ImportExport {
                                $useStorageFromStorageRecords = TRUE;
                        }
 
-                       if (empty($fileRecord['storage'])) {
+                       if (empty($fileRecord['storage']) && !$this->isFallbackStorage($fileRecord['storage'])) {
                                // no storage for the file is defined, mostly because of a missing default storage.
                                $this->error('Error: No storage for the file "' . $fileRecord['identifier'] . '" with storage uid "' . $originalStorageUid . '"');
                                continue;
@@ -1640,6 +1640,8 @@ class ImportExport {
                        if ($useStorageFromStorageRecords && isset($storageRecords[$fileRecord['storage']])) {
                                /** @var $storage \TYPO3\CMS\Core\Resource\ResourceStorage */
                                $storage = \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance()->getStorageObject($fileRecord['storage'], $storageRecords[$fileRecord['storage']]);
+                       } elseif ($this->isFallbackStorage($fileRecord['storage'])) {
+                               $storage = \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance()->getStorageObject(0);
                        } elseif ($defaultStorage !== NULL) {
                                $storage = $defaultStorage;
                        } else {
@@ -1703,6 +1705,16 @@ class ImportExport {
        }
 
        /**
+        * Checks if the $storageId is the id of the fallback storage
+        *
+        * @param int|string $storageId
+        * @return bool
+        */
+       protected function isFallbackStorage($storageId) {
+               return $storageId === 0 || $storageId === '0';
+       }
+
+       /**
         * Normally the importer works like the following:
         * Step 1: import the records with cleared field values of relation fields (see addSingle())
         * Step 2: update the records with the right relation ids (see setRelations())