[BUGFIX] Improve file handling on Windows systems 59/36359/3
authorNicole Cordes <typo3@cordes.co>
Thu, 29 Jan 2015 14:26:43 +0000 (15:26 +0100)
committerChristian Kuhn <lolli@schwarzbu.ch>
Thu, 29 Jan 2015 17:16:37 +0000 (18:16 +0100)
Calling unlink() on a symlink that points to a directory
fails on Windows. Solution is to use rmdir() instead to
remove the symlink.
Furthermore it fixes a wrong usage of DIRECTORY_SEPARATOR
within the FileHandlingUtility.

Releases: master, 6.2
Resolves: #64409
Change-Id: Idc6ff3eb1214ed8f5cb0f69f15a2d5a6a3dcfafe
Reviewed-on: http://review.typo3.org/36359
Reviewed-by: Oliver Klee <typo3-coding@oliverklee.de>
Reviewed-by: Jan Helke <typo3@helke.de>
Reviewed-by: Tymoteusz Motylewski <t.motylewski@gmail.com>
Tested-by: Tymoteusz Motylewski <t.motylewski@gmail.com>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/core/Classes/Utility/GeneralUtility.php
typo3/sysext/extensionmanager/Classes/Utility/FileHandlingUtility.php

index 4cb6a52..a47751c 100755 (executable)
@@ -2874,6 +2874,8 @@ Connection: close
                                if ($OK) {
                                        $OK = @rmdir($path);
                                }
+                       } elseif (is_link($path) && is_dir($path) && TYPO3_OS === 'WIN') {
+                               $OK = rmdir($path);
                        } else {
                                // If $path is a file, simply remove it
                                $OK = unlink($path);
index 8722d46..b30dcdc 100644 (file)
@@ -264,8 +264,9 @@ class FileHandlingUtility implements \TYPO3\CMS\Core\SingletonInterface {
         * @return void
         */
        public function removeDirectory($extDirPath) {
-               $extensionPathWithoutTrailingSlash = rtrim($extDirPath, DIRECTORY_SEPARATOR);
-               if (is_link($extensionPathWithoutTrailingSlash)) {
+               $extDirPath = GeneralUtility::fixWindowsFilePath($extDirPath);
+               $extensionPathWithoutTrailingSlash = rtrim($extDirPath, '/');
+               if (is_link($extensionPathWithoutTrailingSlash) && TYPO3_OS !== 'WIN') {
                        $result = unlink($extensionPathWithoutTrailingSlash);
                } else {
                        $result = GeneralUtility::rmdir($extDirPath, TRUE);