bug47667.phpt 846 B

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