summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2014-06-23 23:18:10 +0200
committerThomas Müller <thomas.mueller@tmit.eu>2014-06-23 23:18:10 +0200
commitf913b1629bb2bfd4e13582b8fbc541424efe2b24 (patch)
tree5cd52e67db2824615a40510a4a99f45c2aed361c /lib
parente070e292bfddc89ddcda251a5f6141e855ef284a (diff)
parentfba694edaeb7c30f4367c30d412cc4c775b95ec3 (diff)
downloadnextcloud-server-f913b1629bb2bfd4e13582b8fbc541424efe2b24.tar.gz
nextcloud-server-f913b1629bb2bfd4e13582b8fbc541424efe2b24.zip
Merge pull request #9158 from owncloud/no-recursion-on-rmdirr-master
fix recursion on rmdirr
Diffstat (limited to 'lib')
-rw-r--r--lib/private/helper.php17
1 files changed, 11 insertions, 6 deletions
diff --git a/lib/private/helper.php b/lib/private/helper.php
index 243baa46948..f90c38d236c 100644
--- a/lib/private/helper.php
+++ b/lib/private/helper.php
@@ -405,12 +405,17 @@ class OC_Helper {
*/
static function rmdirr($dir) {
if (is_dir($dir)) {
- $files = scandir($dir);
- // FIXME: use flat array instead of recursion to avoid
- // too many levels
- foreach ($files as $file) {
- if ($file !== '' && $file !== "." && $file !== "..") {
- self::rmdirr("$dir/$file");
+ $files = new RecursiveIteratorIterator(
+ new RecursiveDirectoryIterator($dir, RecursiveDirectoryIterator::SKIP_DOTS),
+ RecursiveIteratorIterator::CHILD_FIRST
+ );
+
+ foreach ($files as $fileInfo) {
+ /** @var SplFileInfo $fileInfo */
+ if ($fileInfo->isDir()) {
+ rmdir($fileInfo->getRealPath());
+ } else {
+ unlink($fileInfo->getRealPath());
}
}
rmdir($dir);