Handle edge cases too in removeDirectoryPhp to avoid trying to delete symlinks and such, fixes #9955

main
Jordi Boggiano 3 years ago
parent f61f2c6872
commit 6c1f0cdf24
No known key found for this signature in database
GPG Key ID: 7BBD42C429EC80BC

@ -166,7 +166,7 @@ class Filesystem
*
* @return bool|null Returns null, when no edge case was hit. Otherwise a bool whether removal was successfull
*/
private function removeEdgeCases($directory)
private function removeEdgeCases($directory, $fallbackToPhp = true)
{
if ($this->isSymlinkedDirectory($directory)) {
return $this->unlinkSymlinkedDirectory($directory);
@ -188,7 +188,7 @@ class Filesystem
throw new \RuntimeException('Aborting an attempted deletion of '.$directory.', this was probably not intended, if it is a real use case please report it.');
}
if (!\function_exists('proc_open')) {
if (!\function_exists('proc_open') && $fallbackToPhp) {
return $this->removeDirectoryPhp($directory);
}
@ -207,6 +207,11 @@ class Filesystem
*/
public function removeDirectoryPhp($directory)
{
$edgeCaseResult = $this->removeEdgeCases($directory, false);
if ($edgeCaseResult !== null) {
return $edgeCaseResult;
}
try {
$it = new RecursiveDirectoryIterator($directory, RecursiveDirectoryIterator::SKIP_DOTS);
} catch (\UnexpectedValueException $e) {

Loading…
Cancel
Save