[BUGFIX] Correctly treat uploaded file when replacing a file 81/48181/2
authorMarkus Klein <markus.klein@typo3.org>
Tue, 17 May 2016 08:38:28 +0000 (10:38 +0200)
committerOliver Hader <oliver.hader@typo3.org>
Tue, 17 May 2016 11:26:15 +0000 (13:26 +0200)
Uploaded files must be moved with the specific PHP function,
otherwise permissions may be wrong.

Resolves: #76205
Releases: master, 7.6
Change-Id: Ic96e6b8927ed5d21131952004805fa72fb8b6857
Reviewed-on: https://review.typo3.org/48181
Reviewed-by: Andreas Fernandez <typo3@scripting-base.de>
Reviewed-by: Frans Saris <franssaris@gmail.com>
Tested-by: Frans Saris <franssaris@gmail.com>
Reviewed-by: Nicole Cordes <typo3@cordes.co>
Reviewed-by: Oliver Hader <oliver.hader@typo3.org>
Tested-by: Oliver Hader <oliver.hader@typo3.org>
typo3/sysext/core/Classes/Resource/Driver/LocalDriver.php

index 6c389d1..fdf1c48 100644 (file)
@@ -854,7 +854,11 @@ class LocalDriver extends AbstractHierarchicalFilesystemDriver
     public function replaceFile($fileIdentifier, $localFilePath)
     {
         $filePath = $this->getAbsolutePath($fileIdentifier);
-        $result = rename($localFilePath, $filePath);
+        if (is_uploaded_file($localFilePath)) {
+            $result = move_uploaded_file($localFilePath, $filePath);
+        } else {
+            $result = rename($localFilePath, $filePath);
+        }
         GeneralUtility::fixPermissions($filePath);
         if ($result === false) {
             throw new \RuntimeException('Replacing file ' . $fileIdentifier . ' with ' . $localFilePath . ' failed.', 1315314711);