|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #74154 Phar extractTo creates empty files
Submitted: 2017-02-22 22:41 UTC Modified: 2017-02-23 15:14 UTC
From: jlesueur at bamboohr dot com Assigned:
Status: Verified Package: PHAR related
PHP Version: 7.0.16 OS: Ubuntu trusty
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.
Block user comment
Status: Assign to:
Bug Type:
From: jlesueur at bamboohr dot com
New email:
PHP Version: OS:


 [2017-02-22 22:41 UTC] jlesueur at bamboohr dot com
The test script creates a test directory, and 5 text files inside. It then uses loads those files into a PharData file, compresses it, and extracts to a "dest" directory. In php 7.0.15, the files had the correct contents, in 7.0.16, the files in "dest" are empty.

Test script:

`rm -rf test`;
file_put_contents('test/1.txt', str_repeat('h', 10000));
file_put_contents('test/2.txt', str_repeat('e', 10000));
file_put_contents('test/3.txt', str_repeat('l', 10000));
file_put_contents('test/4.txt', str_repeat('l', 10000));
file_put_contents('test/5.txt', str_repeat('o', 10000));
$phar = new PharData('test.tar');
$compPhar = $phar->compress(Phar::GZ);
unset($phar); //make sure that test.tar is closed
unset($compPhar); //make sure that test.tar.gz is closed
$extractingPhar = new PharData('test.tar.gz');


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2017-02-23 13:04 UTC]
-Status: Open +Status: Verified
 [2017-02-23 13:04 UTC]
This regression has been introduced with commit 995ecff[1] which
fixed bug #70417.

[1] <;a=commit;h=995ecffbb2ef972c2d01200ee15b39feb7c6d066>
 [2017-02-23 15:14 UTC] jlesueur at bamboohr dot com
If I understand correctly, the problem is that because the phar is not aliased, it closes the file handle prematurely? Previous versions would have left the file pointer open. Does the line
$extractingPhar = new PharData('test.tar.gz');
try to reuse an existing Phar resource, and get the closed file pointer, and not reopen it?
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Mon Oct 26 14:01:26 2020 UTC