Skip to content

Commit

Permalink
[BUGFIX] Decouple GeneralUtility::rmdir from Environment::isWindows()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
IchHabRecht authored and bmack committed Oct 28, 2018
1 parent 95aeaf1 commit 10d3b0b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions typo3/sysext/core/Classes/Utility/GeneralUtility.php
Expand Up @@ -2187,6 +2187,7 @@ public static function rmdir($path, $removeNonEmpty = false)
$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)) {
Expand All @@ -2202,7 +2203,7 @@ public static function rmdir($path, $removeNonEmpty = false)
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
Expand All @@ -2211,7 +2212,7 @@ public static function rmdir($path, $removeNonEmpty = false)
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);
}
Expand Down

0 comments on commit 10d3b0b

Please sign in to comment.