|  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
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (100.0%)
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
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 — but make sure to vote on the bug!
Your email address:
Solve the problem:
12 + 40 = ?
Subscribe to this entry?

 [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-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 16 05:01:29 2024 UTC