Edit report at https://bugs.php.net/bug.php?id=53467&edit=1
ID: 53467
Patch added by: cmb@php.net
Reported by: mep_eisen at web dot de
Summary: Phar cannot compress large archives
Status: Assigned
Type: Bug
Package: PHAR related
Operating System: Windows 7 - 64
PHP Version: 5.3.3
Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
The following pull request has been associated:
Patch Name: Fix #53467: Phar cannot compress large archives
On GitHub: https://github.com/php/php-src/pull/6643
Patch: https://github.com/php/php-src/pull/6643.patch
Previous Comments:
------------------------------------------------------------------------
[2019-09-02 13:57:14] flavio dot lisboa at fgsl dot eti dot br
I have experienced this bug in Ubuntu 18.04LTS with php 7.2.19.
I removed temp file created by Phar class, but it still fails when compressFiles is called.
------------------------------------------------------------------------
[2018-09-30 16:50:43] cmb@php.net
This is likely a duplicate of bug #70417.
------------------------------------------------------------------------
[2015-05-28 10:10:13] hanskrentel at yahoo dot de
Related:
Bug #58169: "Number of files in the Phar" limited to 2042 (Apr 2008)
https://bugs.php.net/bug.php?id=58169
------------------------------------------------------------------------
[2015-05-28 10:09:15] hanskrentel at yahoo dot de
Related To: Bug #58169
------------------------------------------------------------------------
[2015-03-04 16:06:41] kevin at herrera dot io
Here's a script that will trigger the bug:
(A person also narrowed down the affected C code for the phar extension: https://github.com/box-project/box2/issues/80#issuecomment-77147371
)
----------------------------------------------------
<?php
ini_set('memory_limit', -1);
$max_handles = (int) file_get_contents('/proc/sys/fs/file-max');
if (!is_dir('src')) {
echo "Creating source files...\n";
mkdir('src');
$total_dirs = ceil($max_handles / 1000);
for ($current_dir = 0; $current_dir < $total_dirs; $current_dir++) {
mkdir("src/$current_dir");
for ($current_file = 0; $current_file < 1000; $current_file++) {
touch("src/$current_dir/$current_dir-$current_file.php");
}
}
} else {
echo "Source files already exist, skipping.\n";
}
if (file_exists('bug.phar')) {
echo "Removing previous phar...\n";
unlink('bug.phar');
}
echo "Building new phar...\n";
$phar = new Phar('bug.phar');
$phar->buildFromIterator(
new RecursiveIteratorIterator(
new RecursiveDirectoryIterator(
'src',
FilesystemIterator::SKIP_DOTS
)
),
'src'
);
echo "Compression files in phar...\n";
$phar = new Phar('bug.phar');
$phar->compressFiles(Phar::GZ);
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=53467
--
Edit this bug report at https://bugs.php.net/bug.php?id=53467&edit=1