ZipArchive::open(): Using empty file as ZipArchive is deprecated

This commit is contained in:
Remi Collet 2020-03-20 11:27:42 +01:00
parent 217ff8132e
commit a4d12f46d1
3 changed files with 8 additions and 3 deletions

View File

@ -457,6 +457,11 @@ PHP 8.0 UPGRADE NOTES
4. Deprecated Functionality
========================================
- Zip:
. Using empty file as ZipArchive is deprecated. Libzip 1.6.0
do not accept empty files as valid zip archives any longer.
Existing workaround will be removed in next version.
========================================
5. Changed Functions
========================================

View File

@ -1487,7 +1487,6 @@ static ZIPARCHIVE_METHOD(open)
ze_obj->filename = NULL;
}
#if LIBZIP_VERSION_MAJOR > 1 || LIBZIP_VERSION_MAJOR == 1 && LIBZIP_VERSION_MINOR >= 6
/* reduce BC break introduce in libzip 1.6.0
"Do not accept empty files as valid zip archives any longer" */
@ -1497,10 +1496,10 @@ static ZIPARCHIVE_METHOD(open)
/* exists and is empty */
if (VCWD_STAT(resolved_path, &st) == 0 && st.st_size == 0) {
php_error_docref(NULL, E_DEPRECATED, "Using empty file as ZipArchive is deprecated");
flags |= ZIP_TRUNCATE;
}
}
#endif
intern = zip_open(resolved_path, flags, &err);
if (!intern || err) {

View File

@ -20,5 +20,6 @@ $nx->statName("a",ZIPARCHIVE::FL_UNCHANGED);
$fname = __DIR__."/test53885.zip";
unlink($fname);
?>
--EXPECT--
--EXPECTF--
Deprecated: ZipArchive::open(): Using empty file as ZipArchive is deprecated in %s
==DONE==