php.net |  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: dams@php.net Assigned: cmb (profile)
Status: Not a bug Package: PHAR related
PHP Version: 7.2.6 OS: OSX
Private report: No CVE-ID: None
 [2018-06-14 10:38 UTC] dams@php.net
Description:
------------
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. 

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-01-27 13:04 UTC] cmb@php.net
-Status: Open +Status: Not a bug -Assigned To: +Assigned To: cmb
 [2021-01-27 13:04 UTC] cmb@php.net
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
RecursiveDirectoryIterator::construct().

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: Mon Apr 19 23:01:23 2021 UTC