Bug #53467 [Com]: Phar cannot compress large archives

From: Date: Tue, 08 Oct 2013 14:43:52 +0000
Subject: Bug #53467 [Com]: Phar cannot compress large archives
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-182086@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=53467&edit=1

 ID:                 53467
 Comment by:         Tr at visPaul dot me
 Reported by:        mep_eisen at web dot de
 Summary:            Phar cannot compress large archives
 Status:             Open
 Type:               Bug
 Package:            PHAR related
 Operating System:   Windows 7 - 64
 PHP Version:        5.3.3
 Block user comment: N
 Private report:     N

 New Comment:

I also am seeing this problem in Fedora 19 Php 5.5.1. I found 2 workarounds and I'm curious if
they works for others:

1. Don't attempt to compress the Phar. The compression seems to be the root of the issue and
throws an exception: "unable to create temporary file"

2. Bump the number of max files that you can open by editing /etc/security/limits.conf or similar.

For whatever reason it seems that the Phar's compress method needs to open all of the files at
once. Perhaps a Php Dev can shed some light on this and confirm/deny that it is a bug.


Previous Comments:
------------------------------------------------------------------------
[2013-02-27 16:59:11] cicerchia@php.net

Still present with PHP 5.4 as well (with Ubuntu 12.04).

PHP 5.4.12-1~quantal+1 (cli) (built: Feb 25 2013 19:19:48) 
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
    with Xdebug v2.2.1, Copyright (c) 2002-2012, by Derick Rethans

------------------------------------------------------------------------
[2012-07-27 12:10:16] mep_eisen at web dot de

This bug is still present. The workarounds on large phar files are resulting high cpu-load and
packaging phar in more than 30 mins.

------------------------------------------------------------------------
[2011-09-05 06:15:37] d dot kreuer at kremedia dot de

I have the same problem under Ubuntu 10.04.3 with PHP 5.3.5

PHP 5.3.5-1ubuntu7.2ppa1~lucid with Suhosin-Patch (cli) (built: May  7 2011 
03:15:14) 
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
    with the ionCube PHP Loader v4.0.7, Copyright (c) 2002-2011, by ionCube Ltd.
    with Suhosin v0.9.29, Copyright (c) 2007, by SektionEins GmbH

------------------------------------------------------------------------
[2010-12-03 20:31:20] mep_eisen at web dot de

Description:
------------
I tried to create a large phar (exactly 2347 files). However compressing the phar simply fails. That
may be a similar problem as closed pecl bug: http://pecl.php.net/bugs/bug.php?id=13727

Smaller phars are working. If using the commented section (compress them by hand) it does work but
this is really slow.

Test script:
---------------
<?php
if
(file_exists('D:\\Dev\\ws\\mavenphp-flow3\\FLOW3\\target'.DIRECTORY_SEPARATOR.'FLOW3-1.0.0-alpha-13.phar'))
unlink('D:\\Dev\\ws\\mavenphp-flow3\\FLOW3\\target'.DIRECTORY_SEPARATOR.'FLOW3-1.0.0-alpha-13.phar');
$phar = new
Phar('D:\\Dev\\ws\\mavenphp-flow3\\FLOW3\\target'.DIRECTORY_SEPARATOR.'FLOW3-1.0.0-alpha-13.phar',
0, 'FLOW3-1.0.0-alpha-13.phar');
$phar->startBuffering();

//$localDir =
realpath('D:\\Dev\\ws\\mavenphp-flow3\\FLOW3\\target\\classes\\Packages\\This\\FLOW3');
//$iter = new RecursiveIteratorIterator(new
RecursiveDirectoryIterator(realpath('D:\\Dev\\ws\\mavenphp-flow3\\FLOW3\\target\\classes\\Packages\\This\\FLOW3')));
//foreach ($iter as $file)
//{
//	$pathName = $file->getPathname();
//	$localName = substr($pathName, strlen($localDir));
//	$phar->addFile($pathName, $localName);
//	echo "adding $localName".PHP_EOL;
//	$phar[$localName]->compress(Phar::GZ);
//}
		
$phar->buildFromIterator(new RecursiveIteratorIterator(new
RecursiveDirectoryIterator(realpath('D:\\Dev\\ws\\mavenphp-flow3\\FLOW3\\target\\classes\\Packages\\This\\FLOW3'))),
realpath('D:\\Dev\\ws\\mavenphp-flow3\\FLOW3\\target\\classes\\Packages\\This\\FLOW3'));
echo "packed ".$phar->count()." files".PHP_EOL;
echo "compressing".PHP_EOL;
$phar->compressFiles(Phar::GZ);
$phar->setStub('<?php die(\'Unable to execute this phar\'); __HALT_COMPILER();
?>');
$phar->stopBuffering();


Expected result:
----------------
expected to get the phar.

Actual result:
--------------
BadMethodCallException: unable to create temporary file in D:\Dev\ws\mavenphp-fl
ow3\FLOW3\target\packagePhar.php on line 20

Call Stack:
    0.0011     332160   1. {main}() D:\Dev\ws\mavenphp-flow3\FLOW3\target\packag
ePhar.php:0
    5.1570    1068784   2. Phar->compressFiles() D:\Dev\ws\mavenphp-flow3\FLOW3\
target\packagePhar.php:20


------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=53467&edit=1


Thread (11 messages)

« previous php.bugs (#182086) next »