From d8be9d96edec4ef8934b46e32298dfbed2b2a0a3 Mon Sep 17 00:00:00 2001 From: Sjors van der Pluijm Date: Mon, 28 Apr 2014 10:20:24 +0200 Subject: fixes #8376 --- lib/private/files/storage/local.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'lib/private/files/storage') diff --git a/lib/private/files/storage/local.php b/lib/private/files/storage/local.php index ff2949d33b6..16689ee905c 100644 --- a/lib/private/files/storage/local.php +++ b/lib/private/files/storage/local.php @@ -44,17 +44,20 @@ if (\OC_Util::runningOnWindows()) { new \RecursiveDirectoryIterator($this->datadir . $path), \RecursiveIteratorIterator::CHILD_FIRST ); - foreach ($it as $file) { + while ($it->valid()) { /** * @var \SplFileInfo $file */ + $file = $it->current(); if (in_array($file->getBasename(), array('.', '..'))) { + $it->next(); continue; } elseif ($file->isDir()) { rmdir($file->getPathname()); } elseif ($file->isFile() || $file->isLink()) { unlink($file->getPathname()); } + $it->next(); } return rmdir($this->datadir . $path); } catch (\UnexpectedValueException $e) { -- cgit v1.2.3 From d7ec1fe44721d28cfc93191dc604132df41dd5db Mon Sep 17 00:00:00 2001 From: Sjors van der Pluijm Date: Mon, 28 Apr 2014 13:05:20 +0200 Subject: rewind iterator before iteration starts --- lib/private/files/storage/local.php | 1 + 1 file changed, 1 insertion(+) (limited to 'lib/private/files/storage') diff --git a/lib/private/files/storage/local.php b/lib/private/files/storage/local.php index 16689ee905c..ed2ad870858 100644 --- a/lib/private/files/storage/local.php +++ b/lib/private/files/storage/local.php @@ -44,6 +44,7 @@ if (\OC_Util::runningOnWindows()) { new \RecursiveDirectoryIterator($this->datadir . $path), \RecursiveIteratorIterator::CHILD_FIRST ); + $it->rewind(); while ($it->valid()) { /** * @var \SplFileInfo $file -- cgit v1.2.3 From 54f482ff9cf4e0bae89a85c3c291204da5910d96 Mon Sep 17 00:00:00 2001 From: Sjors van der Pluijm Date: Mon, 28 Apr 2014 19:32:25 +0200 Subject: refs #8376; added comment and applied patch on other files --- apps/files_trashbin/lib/trashbin.php | 10 +++++++++- lib/private/files/storage/local.php | 5 +++++ lib/private/files/storage/mappedlocal.php | 11 ++++++++++- 3 files changed, 24 insertions(+), 2 deletions(-) (limited to 'lib/private/files/storage') diff --git a/apps/files_trashbin/lib/trashbin.php b/apps/files_trashbin/lib/trashbin.php index 9b931333b7f..495532561ea 100644 --- a/apps/files_trashbin/lib/trashbin.php +++ b/apps/files_trashbin/lib/trashbin.php @@ -883,11 +883,19 @@ class Trashbin { $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($root), \RecursiveIteratorIterator::CHILD_FIRST); $size = 0; - foreach ($iterator as $path) { + /** + * RecursiveDirectoryIterator on an NFS path isn't iterable with foreach + * This bug is fixed in PHP 5.5.9 or before + * See #8376 + */ + $iterator->rewind(); + while ($iterator->valid()) { + $path = $iterator->current(); $relpath = substr($path, strlen($root) - 1); if (!$view->is_dir($relpath)) { $size += $view->filesize($relpath); } + $iterator->next(); } return $size; } diff --git a/lib/private/files/storage/local.php b/lib/private/files/storage/local.php index ed2ad870858..de940fc7cdb 100644 --- a/lib/private/files/storage/local.php +++ b/lib/private/files/storage/local.php @@ -44,6 +44,11 @@ if (\OC_Util::runningOnWindows()) { new \RecursiveDirectoryIterator($this->datadir . $path), \RecursiveIteratorIterator::CHILD_FIRST ); + /** + * RecursiveDirectoryIterator on an NFS path isn't iterable with foreach + * This bug is fixed in PHP 5.5.9 or before + * See #8376 + */ $it->rewind(); while ($it->valid()) { /** diff --git a/lib/private/files/storage/mappedlocal.php b/lib/private/files/storage/mappedlocal.php index 75582fd6c83..f995cb00c7a 100644 --- a/lib/private/files/storage/mappedlocal.php +++ b/lib/private/files/storage/mappedlocal.php @@ -39,17 +39,26 @@ class MappedLocal extends \OC\Files\Storage\Common{ new \RecursiveDirectoryIterator($this->buildPath($path)), \RecursiveIteratorIterator::CHILD_FIRST ); - foreach ($it as $file) { + /** + * RecursiveDirectoryIterator on an NFS path isn't iterable with foreach + * This bug is fixed in PHP 5.5.9 or before + * See #8376 + */ + $it->rewind(); + while ($it->valid()) { /** * @var \SplFileInfo $file */ + $file = $it->current(); if (in_array($file->getBasename(), array('.', '..'))) { + $it->next(); continue; } elseif ($file->isDir()) { rmdir($file->getPathname()); } elseif ($file->isFile() || $file->isLink()) { unlink($file->getPathname()); } + $it->next(); } if ($result = @rmdir($this->buildPath($path))) { $this->cleanMapper($path); -- cgit v1.2.3 From e8a287f5bbb07d1c472af83bfe600067b13c7406 Mon Sep 17 00:00:00 2001 From: Sjors van der Pluijm Date: Mon, 28 Apr 2014 19:52:06 +0200 Subject: refs #8376; spaces=>tabs --- lib/private/files/storage/mappedlocal.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/private/files/storage') diff --git a/lib/private/files/storage/mappedlocal.php b/lib/private/files/storage/mappedlocal.php index f995cb00c7a..07691661644 100644 --- a/lib/private/files/storage/mappedlocal.php +++ b/lib/private/files/storage/mappedlocal.php @@ -41,7 +41,7 @@ class MappedLocal extends \OC\Files\Storage\Common{ ); /** * RecursiveDirectoryIterator on an NFS path isn't iterable with foreach - * This bug is fixed in PHP 5.5.9 or before + * This bug is fixed in PHP 5.5.9 or before * See #8376 */ $it->rewind(); -- cgit v1.2.3