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
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: andrey dot budko at gmail dot com
New email:
PHP Version: OS:

 

 [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 Mar 28 13:01:28 2024 UTC