ID:               46985
 Updated by:       paj...@php.net
 Reported By:      killerbg at gmail dot com
 Status:           Feedback
 Bug Type:         Zip Related
 Operating System: Windows XP Professional SP3
 PHP Version:      5.2.8
 Assigned To:      pajoye
 New Comment:

Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/

Please try a 5.2 snapshot, I committed a fix that should fix this
issue.


Previous Comments:
------------------------------------------------------------------------

[2009-01-01 16:25:38] killerbg at gmail dot com

pajoye(at)php(dot)net, here is the output from your script
http://rapidshare.com/files/178740823/ouput.zip.html
(identical with the two versions)
The file working state is the same as with my script
The php(at)undoso(dot)eu's solution is working here too
when combining php5ts.dll version 5.2.9 (CVS)
with php_zip.dll version 5.2.7 (CVS)

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

[2009-01-01 14:44:00] php at undoso dot eu

I have the same issue. It seems that compressing short strings works
fine but using huge ones gets them corrupted. Even if the resulting zip
might open, using a simple md5 on both files often prove that they
differs which is not great...

I downloaded PHP 5.2.6 and replaced the php_zip.dll of 5.2.8 by the
5.2.6 version. It fixed the problem right away. There is really some
kind of regression in 5.2.8.

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

[2009-01-01 00:38:55] paj...@php.net

It works just fine here (in apache2 sapi, iis, fcgi and cli).

Can you try the following script please? I suspect some other errors
happening and they are not displayed. Be sure to have display_errors
activated.

By the way, in the latest releases there are "addFromPattern"/"Glob"
functions which let you add recursively something like "*.jpeg" :)

<?php
$path = 'C:\yourpath\\';
$count = 0;


function archive($path, $local)
{
        global $zip, $count;
        if ($handle = opendir($path)) {
                while (($file = readdir($handle)) !== false) {
                        if (($file != ".") && ($file != "..")) {
                                echo "$file\n";
                                var_dump($local, $file, $path);
                                if (is_dir($path . $file)) {
                                        $zip->addEmptyDir($local . $file . "/");
                                        archive($path . $file . "/", $local . 
$file . "/");
                                } elseif (is_file($path . $file)) {
                                        if ($count > 128) {
                                                $zip->close();
                                                $zip->open($GLOBALS["file"]);
                                                $count = 0;
                                        }
                                        $zip->addFile($path . $file, $local . 
$file);
                                        $count++;
                                }
                        }
                }
                closedir($handle);
        }
        echo "count: $count\n";
}
$file = 't.zip';

$zip = new ZipArchive();

if (($zip->open($file, ZipArchive::CREATE)) === TRUE) {
        archive($path, null);
        $zip->close();

}

echo "done\n";


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

[2008-12-31 23:12:49] killerbg at gmail dot com

Here is an archive containing both the corrupted file created with the
new versions, a good file created with the same script and older version
(5.2.6) and the script used -
http://rapidshare.com/files/178582253/Error.zip.html

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

[2008-12-31 21:21:33] paj...@php.net

I can't reproduce it here (xp sp3 and vista/2k8).

Please provide the file(s) (the minimum required to create a corrupted
archive) and the script you are using.

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

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
    http://bugs.php.net/46985

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

Reply via email to