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
Votes:1
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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: jlesueur at bamboohr dot com
New email:
PHP Version: OS:

 

 [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-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 19:01:31 2024 UTC