1--TEST-- 2Bug #47667 (ZipArchive::OVERWRITE seems to have no effect) 3--SKIPIF-- 4<?php 5if(!extension_loaded('zip')) die('skip'); 6?> 7--FILE-- 8<?php 9$thisdir = dirname(__FILE__); 10$filename = $thisdir . "/bug47667.zip"; 11 12$zip = new ZipArchive(); 13if ($zip->open($filename, ZipArchive::CREATE) !== true) { 14 exit("Unable to open the zip file"); 15} else { 16 $zip->addFromString('foo.txt', 'foo bar foobar'); 17 $zip->close(); 18} 19 20for ($i = 0; $i < 10; $i++) { 21 $zip = new ZipArchive(); 22 if ($zip->open($filename, ZipArchive::OVERWRITE) !== true) { 23 exit("Unable to open the zip file"); 24 } 25 $zip->addFromString("foo_{$i}.txt", 'foo bar foobar'); 26 $zip->close(); 27} 28 29$zip = new ZipArchive(); 30if ($zip->open($filename, ZipArchive::CREATE) !== true) { 31 exit("Unable to open the zip file"); 32} 33 34echo "files: " , $zip->numFiles; 35$zip->close(); 36 37unlink($filename); 38--EXPECT-- 39files: 1 40