[Pkg-owncloud-commits] [owncloud] 14/67: fix recursion on rmdirr

David Prévot taffit at moszumanska.debian.org
Fri Jun 27 23:58:12 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository owncloud.

commit f83821c388120eda258a968cc6be3e1a875ce34c
Author: Thomas Müller <thomas.mueller at tmit.eu>
Date:   Mon Jun 23 13:33:55 2014 +0200

    fix recursion on rmdirr
---
 lib/private/helper.php | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/lib/private/helper.php b/lib/private/helper.php
index 243baa4..206c20d 100644
--- a/lib/private/helper.php
+++ b/lib/private/helper.php
@@ -405,15 +405,19 @@ 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 FilesystemIterator $fileInfo */
+				if ($fileInfo->isDir()) {
+					rmdir($fileInfo->getRealPath());
+				} else {
+					unlink($fileInfo->getRealPath());
 				}
 			}
-			rmdir($dir);
 		} elseif (file_exists($dir)) {
 			unlink($dir);
 		}

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git



More information about the Pkg-owncloud-commits mailing list