|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #80860 Every ((65535*n)-1)th element in glob() and DirectoryIterator() appears twice
Submitted: 2021-03-13 12:02 UTC Modified: 2021-03-13 12:10 UTC
From: andrey dot budko at gmail dot com Assigned: cmb (profile)
Status: Duplicate Package: *Directory/Filesystem functions
PHP Version: 7.4.16 OS: win7, win10
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
28 + 3 = ?
Subscribe to this entry?

 [2021-03-13 12:02 UTC] andrey dot budko at gmail dot com
Every ((65535*n)-1)th element in glob() and DirectoryIterator() appears twice. 

Values of glob() array are not unique.

Test script:

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()){
  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


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2021-03-13 12:10 UTC]
-Status: Open +Status: Duplicate -Assigned To: +Assigned To: cmb
 [2021-03-13 12:10 UTC]
This is a duplicate of bug #36365, which cannot be fixed for PHP
7.4 for BC reasons.
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Wed Jun 23 00:01:23 2021 UTC