Bug #74154 [Ver]: Phar extractTo creates empty files

From: Date: Thu, 23 Feb 2017 15:14:11 +0000
Subject: Bug #74154 [Ver]: Phar extractTo creates empty files
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-207523@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=74154&edit=1 ID: 74154 User updated by: jlesueur at bamboohr dot com Reported by: jlesueur at bamboohr dot com Summary: Phar extractTo creates empty files Status: Verified Type: Bug Package: PHAR related Operating System: Ubuntu trusty PHP Version: 7.0.16 Block user comment: N Private report: N New Comment: 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? Previous Comments: ------------------------------------------------------------------------ [2017-02-23 13:04:43] 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-22 22:41:53] 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'); ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=74154&edit=1

« previous php.bugs (#207523) next »