[BUGFIX] Decouple GeneralUtility::rmdir from Environment::isWindows() 31/58631/2
authorNicole Cordes <typo3@cordes.co>
Sun, 14 Oct 2018 19:12:42 +0000 (21:12 +0200)
committerBenni Mack <benni@typo3.org>
Sun, 28 Oct 2018 10:43:40 +0000 (11:43 +0100)
To be able to call rmdir without an initialized Environment instance,
the check if a Windows system is used, is decoupled. This allows to
call GeneralUtility::rmdir e.g. in typo3/testing-framework.

Resolves: #86655
Releases: master
Change-Id: Ica1feafbd9a07005c4b653ef2fe1153fba4b9417
Reviewed-on: https://review.typo3.org/58631
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Susanne Moog <susanne.moog@typo3.org>
Tested-by: Susanne Moog <susanne.moog@typo3.org>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Benni Mack <benni@typo3.org>
Tested-by: Benni Mack <benni@typo3.org>
typo3/sysext/core/Classes/Utility/GeneralUtility.php

index f68d5b9..5e6073a 100644 (file)
@@ -2187,6 +2187,7 @@ class GeneralUtility
         $OK = false;
         // Remove trailing slash
         $path = preg_replace('|/$|', '', $path);
+        $isWindows = DIRECTORY_SEPARATOR === '\\';
         if (file_exists($path)) {
             $OK = true;
             if (!is_link($path) && is_dir($path)) {
@@ -2202,7 +2203,7 @@ class GeneralUtility
                 if ($OK) {
                     $OK = @rmdir($path);
                 }
-            } elseif (is_link($path) && is_dir($path) && Environment::isWindows()) {
+            } elseif (is_link($path) && is_dir($path) && $isWindows) {
                 $OK = @rmdir($path);
             } else {
                 // If $path is a file, simply remove it
@@ -2211,7 +2212,7 @@ class GeneralUtility
             clearstatcache();
         } elseif (is_link($path)) {
             $OK = @unlink($path);
-            if (!$OK && Environment::isWindows()) {
+            if (!$OK && $isWindows) {
                 // Try to delete dead folder links on Windows systems
                 $OK = @rmdir($path);
             }