Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RecursiveDirectoryIterator does not work on NFS #8376

Closed
pluijm opened this issue Apr 28, 2014 · 2 comments
Closed

RecursiveDirectoryIterator does not work on NFS #8376

pluijm opened this issue Apr 28, 2014 · 2 comments
Labels

Comments

@pluijm
Copy link
Contributor

pluijm commented Apr 28, 2014

See https://github.com/owncloud/core/blob/master/lib/private/files/storage/local.php#L44

I know this is a PHP bug, but it can be avoided. This might be related to https://bugs.php.net/bug.php?id=54256

Please use

<?php
$it->rewind();
while ($it->valid()) {
    echo $it->current()->getBasename().PHP_EOL;
    $it->next();
}
?>

In favor of

<?php
foreach ($it as $file) {
    echo $file->getBasename().PHP_EOL;
}
?>

Steps to reproduce

  1. Given $DIR is on an NFS mount
  2. mkdir $DIR/test
  3. touch $DIR/test/foo.bar
  4. cd $DIR
  5. Run:
<?php
$path = getcwd().'/test';
$it = new \RecursiveIteratorIterator(
    new \RecursiveDirectoryIterator($path),
    \RecursiveIteratorIterator::CHILD_FIRST
);
echo 'Test with foreach: '.PHP_EOL;
foreach ($it as $file) {
    echo $file->getBasename().PHP_EOL;
}
?>
  1. Run:
<?php
$path = getcwd().'/test';
$it = new \RecursiveIteratorIterator(
    new \RecursiveDirectoryIterator($path),
    \RecursiveIteratorIterator::CHILD_FIRST
);
echo 'Test with while: '.PHP_EOL;
$it->rewind();
while ($it->valid()) {
    echo $it->current()->getBasename().PHP_EOL;
    $it->next();
}
?>

Expected behaviour

Test with foreach:
foo.bar
..
Test with while: 
.
foo.bar
..

Actual behaviour

Test with foreach:
Test with while: 
.
foo.bar
..

The foreach fails.

Server configuration

Operating system:
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 12.04.4 LTS
Release: 12.04
Codename: precise

Web server:
Server version: Apache/2.2.22 (Ubuntu)
Server built: Mar 19 2014 21:11:10

Database:
psql (PostgreSQL) 9.1.9

PHP version:
PHP 5.3.10-1ubuntu3.11 with Suhosin-Patch (cli) (built: Apr 4 2014 01:30:04)

ownCloud version: (see ownCloud admin page)
ownCloud 6.0.2 (git)

Updated from an older ownCloud or fresh install:
fresh install

List of activated apps:
none

The content of config/config.php:
Upon request

Are you using external storage, if yes which one: local/smb/sftp/...
NFS3 on a local mount

Are you using encryption: yes/no
encripted partition

Client configuration

Browser:
N/A

Operating system:
N/A

Logs

Web server error log

N/A

ownCloud log (data/owncloud.log)

N/A

Browser log

N/A

@pluijm
Copy link
Contributor Author

pluijm commented Apr 28, 2014

Additional information:
I've tested this with PHP5.5.9 on a NFS4 mount without any problems

@DeepDiver1975
Copy link
Member

@icewind1991 @bantu @karlitschek Can you please have a look?

@pluijm Thanks a lot for digging into this! Can I ask you to open a pull request and contribute your fix? THX

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants