|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #49938 Phar::isBuffering() returns inverted value
Submitted: 2009-10-21 07:57 UTC Modified: 2010-01-11 10:58 UTC
Avg. Score:5.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: nodkz at mail dot ru Assigned: cellog
Status: Closed Package: PHAR related
PHP Version: 5.3.1RC2 OS: Windows XP
Private report: No CVE-ID:
 [2009-10-21 07:57 UTC] nodkz at mail dot ru
I need add 100 000 files to phar arhive.
First 1000 files insert very quick. But when I insert from 9000 to 10000, it works about 20 minutes.

I found that every changes writes to disk. In documentation I so buffering operation to maket set of change, before writing to disk. If I run startBuffering()/stopBuffering() commands.

So I try to run startBuffering() on PHP 5.2.11 - it doesn't work.
So I install PHP5.3.1RC2 - it doesn't work again.

Reproduce code:
$phar = new Phar('test.phar');

for($i=0;$i<100000;$i++) {
   // write data in files  XXX/XXX.txt
   $phar->addFromString( floor($i/1000).'/'.($i%1000).'txt', 'some data');

Expected result:
Expect to see

Actual result:
But scripts shows: 


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2009-11-13 00:16 UTC]
The only bug is that Phar::isBuffering() has its values inverted.

It is not performant to use the buffering feature for extremely large phar archives.  Instead, use this code:

mkdir(__DIR__ . '/fillit');
for($i=0;$i<100000;$i++) {
   // write data in files  XXX/XXX.txt
   @mkdir(__DIR__ . '/fillit/' . floor($i/1000));
   file_put_contents(__DIR__ . '/fillit/' . floor($i/1000).'/'.($i%1000).'txt', 'some
   echo $i,"\n";

echo "building\n";
$phar = new Phar('test1.phar');
$a = time(true);
$phar->buildFromDirectory(__DIR__ . '/fillit');
$b = time(true);
echo "done in ", $b - $a, " seconds\n";
echo count($phar),"\n";

I get 100000 files added in approximately 118 seconds.  The code you supplied takes well over that just for the first 10000 files.

 [2009-11-13 00:58 UTC]
Automatic comment from SVN on behalf of cellog
Log: fix PHP Bug #49938: Phar::isBuffering() returns inverted value
 [2010-01-11 10:58 UTC]
This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
Thank you for the report, and for helping us make PHP better.

PHP Copyright © 2001-2015 The PHP Group
All rights reserved.
Last updated: Wed Oct 07 19:01:32 2015 UTC