mkoppanen               Mon Mar 16 10:22:13 2009 UTC

  Added files:                 (Branch: PHP_5_2)
    /php-src/ext/zip/tests      bug47667.phpt 

  Modified files:              
    /php-src/ext/zip/lib        zip_open.c 
  Log:
  Closes bug #47667
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/zip/lib/zip_open.c?r1=1.1.2.11&r2=1.1.2.12&diff_format=u
Index: php-src/ext/zip/lib/zip_open.c
diff -u php-src/ext/zip/lib/zip_open.c:1.1.2.11 
php-src/ext/zip/lib/zip_open.c:1.1.2.12
--- php-src/ext/zip/lib/zip_open.c:1.1.2.11     Thu Jan  1 19:32:45 2009
+++ php-src/ext/zip/lib/zip_open.c      Mon Mar 16 10:22:13 2009
@@ -65,6 +65,10 @@
     struct zip_cdir *cdir;
     int i;
     off_t len;
+
+    if (flags & ZIP_OVERWRITE) {
+       return _zip_allocate_new(fn, zep);
+    }
     
     switch (_zip_file_exists(fn, flags, zep)) {
     case -1:

http://cvs.php.net/viewvc.cgi/php-src/ext/zip/tests/bug47667.phpt?view=markup&rev=1.1
Index: php-src/ext/zip/tests/bug47667.phpt
+++ php-src/ext/zip/tests/bug47667.phpt
--TEST--
Bug #47667 (ZipArchive::OVERWRITE seems to have no effect)
--SKIPIF--
<?php
/* $Id: bug47667.phpt,v 1.1 2009/03/16 10:16:16 mkoppanen Exp $ */
if(!extension_loaded('zip')) die('skip');
?>
--FILE--
<?php
$thisdir = dirname(__FILE__);
$filename = $thisdir . "/bug47667.zip";

$zip = new ZipArchive();
if ($zip->open($filename, ZipArchive::CREATE) !== true) {
        exit("Unable to open the zip file");
} else {
        $zip->addFromString('foo.txt', 'foo bar foobar');
        $zip->close();
}

for ($i = 0; $i < 10; $i++) {
        $zip = new ZipArchive();
        if ($zip->open($filename, ZipArchive::OVERWRITE) !== true) {
                exit("Unable to open the zip file");
        }       
        $zip->addFromString("foo_{$i}.txt", 'foo bar foobar');
        $zip->close();
}

$zip = new ZipArchive();
if ($zip->open($filename, ZipArchive::CREATE) !== true) {
        exit("Unable to open the zip file");
}

echo "files: " , $zip->numFiles;

unlink($filename);

--EXPECT--
files: 1



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to