Bug #79633 [Com]: readdir skips entries
| From: | keith at ksmith dot com | Date: | Tue, 26 May 2020 02:11:12 +0000 |
| Subject: | Bug #79633 [Com]: readdir skips entries | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-227163@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=79633&edit=1
ID: 79633
Comment by: keith at ksmith dot com
Reported by: keith at ksmith dot com
Summary: readdir skips entries
Status: Open
Type: Bug
Package: Directory function related
Operating System: Ubuntu 18.04, Others
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
This issue occurs direct, and over NFS. Tested with various versions of PHP 5 and 7, available
with Debian, and on a Synology NAS. Extending to the character range [0-9,A-Z] for the folder names
leaves out a number of other single letter named folders.
Code indicates function calls php_stream_readdir which in turn calls php_stream_read, rather than
the C language readdir function. I will likely hack up some code to use the 'C' library
directly, I'm not sure why that call is so indirect/obfuscated.
Previous Comments:
------------------------------------------------------------------------
[2020-05-26 02:03:17] keith at ksmith dot com
Description:
------------
root@nas-2:/volume1/admin/bin# mkdir /volume1/media/testfolder/0
root@nas-2:/volume1/admin/bin# mkdir /volume1/media/testfolder/1
root@nas-2:/volume1/admin/bin# mkdir /volume1/media/testfolder/2
root@nas-2:/volume1/admin/bin# mkdir /volume1/media/testfolder/3
root@nas-2:/volume1/admin/bin# mkdir /volume1/media/testfolder/4
root@nas-2:/volume1/admin/bin# mkdir /volume1/media/testfolder/5
root@nas-2:/volume1/admin/bin# ls /volume1/media/testfolder
0 1 2 3 4 5
root@nas-2:/volume1/admin/bin# php PHP-test.php
Array
(
[0] => ..
[1] => 1
[2] => 3
[3] => 4
[4] => 5
)
See Code below
Test script:
---------------
#!/usr/bin/php
<?php
$cur_folder = "/volume1/media/testfolder";
$dirp = opendir($cur_folder);
while($entry = readdir($dirp)) {
$entry_list[] = $entry;
}
sort($entry_list);
print_r($entry_list);
?>
Expected result:
----------------
I would expect to see the entries: "." and "2"
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=79633&edit=1