Skip to content

Commit a4d12f4

Browse files
committed
ZipArchive::open(): Using empty file as ZipArchive is deprecated
1 parent 217ff81 commit a4d12f4

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

UPGRADING

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,11 @@ PHP 8.0 UPGRADE NOTES
457457
4. Deprecated Functionality
458458
========================================
459459

460+
- Zip:
461+
. Using empty file as ZipArchive is deprecated. Libzip 1.6.0
462+
do not accept empty files as valid zip archives any longer.
463+
Existing workaround will be removed in next version.
464+
460465
========================================
461466
5. Changed Functions
462467
========================================

ext/zip/php_zip.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1487,7 +1487,6 @@ static ZIPARCHIVE_METHOD(open)
14871487
ze_obj->filename = NULL;
14881488
}
14891489

1490-
#if LIBZIP_VERSION_MAJOR > 1 || LIBZIP_VERSION_MAJOR == 1 && LIBZIP_VERSION_MINOR >= 6
14911490
/* reduce BC break introduce in libzip 1.6.0
14921491
"Do not accept empty files as valid zip archives any longer" */
14931492

@@ -1497,10 +1496,10 @@ static ZIPARCHIVE_METHOD(open)
14971496

14981497
/* exists and is empty */
14991498
if (VCWD_STAT(resolved_path, &st) == 0 && st.st_size == 0) {
1499+
php_error_docref(NULL, E_DEPRECATED, "Using empty file as ZipArchive is deprecated");
15001500
flags |= ZIP_TRUNCATE;
15011501
}
15021502
}
1503-
#endif
15041503

15051504
intern = zip_open(resolved_path, flags, &err);
15061505
if (!intern || err) {

ext/zip/tests/bug53885.phpt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,6 @@ $nx->statName("a",ZIPARCHIVE::FL_UNCHANGED);
2020
$fname = __DIR__."/test53885.zip";
2121
unlink($fname);
2222
?>
23-
--EXPECT--
23+
--EXPECTF--
24+
Deprecated: ZipArchive::open(): Using empty file as ZipArchive is deprecated in %s
2425
==DONE==

0 commit comments

Comments
 (0)