summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikko Koppanen <mkoppanen@php.net>2009-03-16 10:19:43 +0000
committerMikko Koppanen <mkoppanen@php.net>2009-03-16 10:19:43 +0000
commit5645de756dc42fdcd7787011e01de6c59c6d8645 (patch)
treeb964c86717e29161ec2ebaebd8deb9adef53f835
parent39988315e0f2067ac77dfe3f3d6d4c13b338628f (diff)
downloadphp-git-5645de756dc42fdcd7787011e01de6c59c6d8645.tar.gz
Closes bug #47667
-rw-r--r--ext/zip/lib/zip_open.c3
-rw-r--r--ext/zip/tests/bug47667.phpt40
2 files changed, 43 insertions, 0 deletions
diff --git a/ext/zip/lib/zip_open.c b/ext/zip/lib/zip_open.c
index cd78281790..dbab6ec4af 100644
--- a/ext/zip/lib/zip_open.c
+++ b/ext/zip/lib/zip_open.c
@@ -66,6 +66,9 @@ zip_open(const char *fn, int flags, int *zep)
int i;
off_t len;
+ if (flags & ZIP_OVERWRITE) {
+ return _zip_allocate_new(fn, zep);
+ }
switch (_zip_file_exists(fn, flags, zep)) {
case -1:
diff --git a/ext/zip/tests/bug47667.phpt b/ext/zip/tests/bug47667.phpt
new file mode 100644
index 0000000000..960a3c5d7e
--- /dev/null
+++ b/ext/zip/tests/bug47667.phpt
@@ -0,0 +1,40 @@
+--TEST--
+Bug #47667 (ZipArchive::OVERWRITE seems to have no effect)
+--SKIPIF--
+<?php
+/* $Id$ */
+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