[BUGFIX] Use temporary directory for exporting files 36/61336/3
authorBenni Mack <benni@typo3.org>
Mon, 22 Jul 2019 10:56:34 +0000 (12:56 +0200)
committerSusanne Moog <look@susi.dev>
Tue, 23 Jul 2019 05:57:40 +0000 (07:57 +0200)
When adding exports into fileadmin, the files
are stored in a temporary folder, which is located
in typo3temp/var/transient/ - this folder does not
need to be accessed via FAL, as it also adds
some issues when this file is not inside the
document root, for this reason, the code is adapted
to work with the native File System directly, and
when moving to fileadmin/user_upload/_temp_/impexp/
then FAL is used again.

Resolves: #88815
Releases: master, 9.5
Change-Id: I633a5dbda595bef73b7420ad511e03c0f7054972
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/61336
Tested-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Tested-by: TYPO3com <noreply@typo3.com>
Tested-by: Susanne Moog <look@susi.dev>
Reviewed-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Reviewed-by: Susanne Moog <look@susi.dev>
typo3/sysext/impexp/Classes/Controller/ExportController.php

index fafa301..49822a5 100644 (file)
@@ -34,8 +34,6 @@ use TYPO3\CMS\Core\Messaging\FlashMessage;
 use TYPO3\CMS\Core\Messaging\FlashMessageService;
 use TYPO3\CMS\Core\Resource\Exception\ExistingTargetFileNameException;
 use TYPO3\CMS\Core\Resource\Folder;
-use TYPO3\CMS\Core\Resource\ResourceFactory;
-use TYPO3\CMS\Core\Resource\ResourceInterface;
 use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Utility\MathUtility;
@@ -322,19 +320,17 @@ class ExportController extends ImportExportController
                 $lang = $this->getLanguageService();
                 if ($saveFolder instanceof Folder && $saveFolder->checkActionPermission('write')) {
                     $temporaryFileName = GeneralUtility::tempnam('export');
-                    file_put_contents($temporaryFileName, $out);
+                    GeneralUtility::writeFile($temporaryFileName, $out);
                     $file = $saveFolder->addFile($temporaryFileName, $dlFile, 'replace');
                     if ($saveFilesOutsideExportFile) {
                         $filesFolderName = $dlFile . '.files';
                         $filesFolder = $saveFolder->createFolder($filesFolderName);
-                        $temporaryFolderForExport = ResourceFactory::getInstance()->retrieveFileOrFolderObject($this->export->getTemporaryFilesPathForExport());
-                        if ($temporaryFolderForExport instanceof ResourceInterface) {
-                            $temporaryFilesForExport = $temporaryFolderForExport->getFiles();
-                            foreach ($temporaryFilesForExport as $temporaryFileForExport) {
-                                $filesFolder->getStorage()->moveFile($temporaryFileForExport, $filesFolder);
-                            }
-                            $temporaryFolderForExport->delete();
+                        $temporaryFilesForExport = GeneralUtility::getFilesInDir($this->export->getTemporaryFilesPathForExport(), '', true);
+                        foreach ($temporaryFilesForExport as $temporaryFileForExport) {
+                            $filesFolder->addFile($temporaryFileForExport);
+                            GeneralUtility::unlink_tempfile($temporaryFileForExport);
                         }
+                        GeneralUtility::rmdir($this->export->getTemporaryFilesPathForExport());
                     }
 
                     /** @var FlashMessage $flashMessage */