diff --git a/setup/setuputils.class.inc.php b/setup/setuputils.class.inc.php index 183eaf628..d788e49a2 100644 --- a/setup/setuputils.class.inc.php +++ b/setup/setuputils.class.inc.php @@ -471,16 +471,30 @@ class SetupUtils throw new Exception("Attempting to delete directory: '$dir'"); } - foreach(glob($dir . '/*') as $file) + $aFiles = scandir($dir); // Warning glob('.*') does not seem to return the broken symbolic links, thus leaving a non-empty directory + if ($aFiles !== false) { - if(is_dir($file)) + foreach($aFiles as $file) { - self::tidydir($file); - rmdir($file); - } - else - { - unlink($file); + if (($file != '.') && ($file != '..')) + { + if(is_dir($dir.'/'.$file)) + { + self::tidydir($dir.'/'.$file); + rmdir($dir.'/'.$file); + } + else + { + if (!unlink($dir.'/'.$file)) + { + SetupPage::log("Warning - FAILED to remove file '$dir/$file'"); + } + else if (file_exists($dir.'/'.$file)) + { + SetupPage::log("Warning - FAILED to remove file '$dir/.$file'"); + } + } + } } } }