|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #46060 Phar::addEmptyDir() breaks
Submitted: 2008-09-12 03:33 UTC Modified: 2008-09-13 20:57 UTC
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: xl269 at cam dot ac dot uk Assigned: cellog (profile)
Status: Closed Package: PHAR related
PHP Version: 5.3.0alpha2 OS: Debian GNU/Linux lenny
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:
25 - 8 = ?
Subscribe to this entry?

 [2008-09-12 03:33 UTC] xl269 at cam dot ac dot uk
PharData::addEmptyDir() on a tar archive adds empty files instead of directories.

Reproduce code:
$zip = new PharData('test.tar');
$zip = $zip->convertToData(Phar::TAR, Phar::NONE); // compression scheme does not affect the result.
// Phar::ZIP is not buggy, but you need to add a file to the empty directory to see this.
// $zip->addFile('file', 'test/file'); // see (*)

Expected result:
test.tar.bz2 should contain 1 empty directory "test"

Actual result:
test.tar.bz2 contains 1 empty *file* "test"

(*) doing this will create the directory "test" automatically, so that the tar archive now contains both a file and a directory called "test", and becomes unextractable.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2008-09-12 03:49 UTC] xl269 at cam dot ac dot uk
whoops, the "* result" sections should read "test.tar" not "test.tar.bz2" (if it isn't obvious). i was playing around with the bug whilst editing this report, and overlooked updating that part.
 [2008-09-12 16:43 UTC] xl269 at cam dot ac dot uk
the following will create an empty directory "test"
$zip->addFromString("test/", "");
 [2008-09-13 20:57 UTC]
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
Thank you for the report, and for helping us make PHP better.

fixed in 5.3, HEAD and pecl, thanks for the report
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Fri Sep 17 05:03:37 2021 UTC