php.net |  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:
MUST BE VALID
Solve the problem:
23 - 10 = ?
Subscribe to this entry?

 
 [2021-03-13 12:02 UTC] 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




Patches

Add a Patch

Pull Requests

Add a Pull Request

History

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