Bug #80860 [Opn->Dup]: Every ((65535*n)-1)th element in glob() and DirectoryIterator() appears twice
| From: | cmb@php.net | Date: | Sat, 13 Mar 2021 12:10:14 +0000 |
| Subject: | Bug #80860 [Opn->Dup]: Every ((65535*n)-1)th element in glob() and DirectoryIterator() appears twice | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-232685@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=80860&edit=1
ID: 80860
Updated by: cmb@php.net
Reported by: andrey dot budko at gmail dot com
Summary: Every ((65535*n)-1)th element in glob() and
DirectoryIterator() appears twice
-Status: Open
+Status: Duplicate
Type: Bug
Package: *Directory/Filesystem functions
Operating System: win7, win10
PHP Version: 7.4.16
-Assigned To:
+Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
This is a duplicate of bug #36365, which cannot be fixed for PHP
7.4 for BC reasons.
Previous Comments:
------------------------------------------------------------------------
[2021-03-13 12:02:31] andrey dot budko at gmail dot com
Description:
------------
Every ((65535*n)-1)th element in glob() and DirectoryIterator() appears twice.
Values of glob() array are not unique.
Test script:
---------------
<?php
function foo($tmp_dir, $count){
for($i = 1; $i <= $count; $i++){
@mkdir($tmp_dir.'/'.$i, 0777, true);
}
$count_glob = count(glob($tmp_dir.'/*'), GLOB_ONLYDIR);
$count_dir_iterator = 0;
$dir = new \DirectoryIterator($tmp_dir);
foreach($dir as $fileInfo){
if($fileInfo->isDir() && !$fileInfo->isDot()){
$count_dir_iterator++;
}
}
return [$count_glob, $count_dir_iterator];
}
echo foo('d:/test', 65533)."\n"; // 65533
echo foo('d:/test', 65534)."\n"; // 65535
echo foo('d:/test', 131068)."\n"; // 131069
echo foo('d:/test', 131069)."\n"; // 131071
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=80860&edit=1