Skip to content

RecursiveDirectoryIterator does not work on NFS #8376

@pluijm

Description

@pluijm

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions