|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #76475 phar buildFromIterator misses some directory informations
Submitted: 2018-06-14 10:38 UTC Modified: 2021-01-27 13:04 UTC
From: Assigned: cmb (profile)
Status: Not a bug Package: PHAR related
PHP Version: 7.2.6 OS: OSX
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:
26 - 24 = ?
Subscribe to this entry?

 [2018-06-14 10:38 UTC]
When building a phar with addFile, it is possible to list the folders with scandir or opendir. 
When building the same phar with buildFromIterator, some of the folders in the phar archive can't be read. I get the following error : 

PHP Warning:  scandir(phar:///tmp/iterator.phar/folder/sub): failed to open dir: operation failed in phar:///tmp/iterator.phar/test on line 3

Test script:
The attached gist creates a few files, and build 2 phar with the same structure.
The one created with iterator fails, while the other one is OK, displaying a folder listing.

Expected result:
Building phar with archives allows for all folder listing.

Actual result:
error when using scandir, opendir in the phar. 


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2021-01-27 13:04 UTC]
-Status: Open +Status: Not a bug -Assigned To: +Assigned To: cmb
 [2021-01-27 13:04 UTC]
In the given test script, the ::addFile() variant explicitly skips
`.` and `..`.  To archive the same for ::buildFromIterator(), you
have to pass FilesystemIterator::SKIP_DOTS as $flags to

So this is not a bug, and there is already request #72046
regarding supporting directories.
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Fri Apr 23 12:01:22 2021 UTC