]> granicus.if.org Git - php/commitdiff
ZipArchive::open(): Using empty file as ZipArchive is deprecated
authorRemi Collet <remi@php.net>
Fri, 20 Mar 2020 10:27:42 +0000 (11:27 +0100)
committerRemi Collet <remi@php.net>
Fri, 20 Mar 2020 10:27:42 +0000 (11:27 +0100)
UPGRADING
ext/zip/php_zip.c
ext/zip/tests/bug53885.phpt

index a5984b4ea85b967a7ef596c4129e314f8cf9bec2..8f30bcaae93eb973dac546044ab6db8b719e76bf 100644 (file)
--- a/UPGRADING
+++ b/UPGRADING
@@ -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
 ========================================
index fb9d3aefec8894c3ae21a57a50fd32f94c21f439..2a3537a8cae806b9e9197718b9b736b307b3731d 100644 (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) {
index 6f95a661b323bad98a51615936b9cde28cc710f0..a522aa1ab2cab2a00df42df2d4bd711db484ccb4 100644 (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==