mirror of
https://github.com/php/php-src.git
synced 2024-09-23 10:57:26 +00:00
d65a520b1d
If Zip operations fails due to PHP error conditions before libzip even has been called, there is no meaningful indication what failed; the functions just return false, and the Zip status indicated that no error did occur. Therefore we raise `E_WARNING` in these cases. Closes GH-6356.
44 lines
886 B
PHP
44 lines
886 B
PHP
--TEST--
|
|
Bug #64342 ZipArchive::addFile() has to check file existence (variation 2)
|
|
--SKIPIF--
|
|
<?php
|
|
if(!extension_loaded('zip')) die('skip');
|
|
?>
|
|
--FILE--
|
|
<?php
|
|
|
|
$dirname = __DIR__ . '/';
|
|
include $dirname . 'utils.inc';
|
|
$file = $dirname . '__私はガラスを食べられますtmp_oo_addfile.zip';
|
|
|
|
copy($dirname . 'test.zip', $file);
|
|
|
|
$zip = new ZipArchive;
|
|
if (!$zip->open($file)) {
|
|
exit('failed');
|
|
}
|
|
if (!$zip->addFile($dirname . 'cant_find_me.txt', 'test.php')) {
|
|
echo "failed\n";
|
|
}
|
|
if ($zip->status == ZIPARCHIVE::ER_OK) {
|
|
if (!verify_entries($zip, [
|
|
"bar",
|
|
"foobar/",
|
|
"foobar/baz",
|
|
"entry1.txt"
|
|
])) {
|
|
echo "failed\n";
|
|
} else {
|
|
echo "OK";
|
|
}
|
|
$zip->close();
|
|
} else {
|
|
echo "failed\n";
|
|
}
|
|
@unlink($file);
|
|
?>
|
|
--EXPECTF--
|
|
Warning: ZipArchive::addFile(): No such file or directory in %s on line %d
|
|
failed
|
|
OK
|