php.net |  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
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:
MUST BE VALID
Solve the problem:
38 + 20 = ?
Subscribe to this entry?

 
 [2017-02-22 22:41 UTC] jlesueur at bamboohr dot com
Description:
------------
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:
---------------
<?php

`rm -rf test`;
mkdir('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');
$phar->buildFromDirectory('test');
$compPhar = $phar->compress(Phar::GZ);
unset($phar); //make sure that test.tar is closed
unlink('test.tar');
unset($compPhar); //make sure that test.tar.gz is closed
$extractingPhar = new PharData('test.tar.gz');
$extractingPhar->extractTo('dest');



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

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

[1] <http://git.php.net/?p=php-src.git;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-2019 The PHP Group
All rights reserved.
Last updated: Sun Feb 17 06:01:25 2019 UTC