1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

ext/zip: Sync remaining parts for libzip >= 1.0.0 (#20365)

Follow up of GH-20355
This commit is contained in:
Peter Kokot
2025-11-02 20:45:04 +01:00
committed by GitHub
parent 9300a5076d
commit 8d1a42fd10
6 changed files with 2 additions and 24 deletions

View File

@@ -17,7 +17,7 @@ if (PHP_ZIP != "no") {
}
AC_DEFINE('HAVE_ZIP', 1, "Define to 1 if the PHP extension 'zip' is available.");
ADD_FLAG("CFLAGS_ZIP", "/D HAVE_SET_MTIME /D HAVE_ENCRYPTION /D HAVE_LIBZIP_VERSION /D HAVE_PROGRESS_CALLBACK /D HAVE_CANCEL_CALLBACK /D HAVE_METHOD_SUPPORTED /D LZMA_API_STATIC");
ADD_FLAG("CFLAGS_ZIP", "/D HAVE_ENCRYPTION /D HAVE_LIBZIP_VERSION /D HAVE_PROGRESS_CALLBACK /D HAVE_CANCEL_CALLBACK /D HAVE_METHOD_SUPPORTED /D LZMA_API_STATIC");
} else {
WARNING("zip not enabled; libraries and headers not found");
}

View File

@@ -2424,7 +2424,6 @@ PHP_METHOD(ZipArchive, setCompressionIndex)
}
/* }}} */
#ifdef HAVE_SET_MTIME
/* {{{ Set the modification time of a file in zip, using its name */
PHP_METHOD(ZipArchive, setMtimeName)
{
@@ -2477,7 +2476,6 @@ PHP_METHOD(ZipArchive, setMtimeIndex)
(time_t)mtime, (zip_uint32_t)flags) == 0);
}
/* }}} */
#endif
/* {{{ Delete a file using its index */
PHP_METHOD(ZipArchive, deleteIndex)

View File

@@ -704,13 +704,11 @@ class ZipArchive implements Countable
/** @tentative-return-type */
public function setCommentName(string $name, string $comment): bool {}
#ifdef HAVE_SET_MTIME
/** @tentative-return-type */
public function setMtimeIndex(int $index, int $timestamp, int $flags = 0): bool {}
/** @tentative-return-type */
public function setMtimeName(string $name, int $timestamp, int $flags = 0): bool {}
#endif
/** @tentative-return-type */
public function getCommentIndex(int $index, int $flags = 0): string|false {}

View File

@@ -1,5 +1,5 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: 53e04d9b2c25cc8a0c9fe51914b5a47280834fb8 */
* Stub hash: 1f77735273373672b9c8c5b92c46e23ea99faeaf */
ZEND_BEGIN_ARG_INFO_EX(arginfo_zip_open, 0, 0, 1)
ZEND_ARG_TYPE_INFO(0, filename, IS_STRING, 0)
@@ -138,7 +138,6 @@ ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_ZipArchive_setCo
ZEND_ARG_TYPE_INFO(0, comment, IS_STRING, 0)
ZEND_END_ARG_INFO()
#if defined(HAVE_SET_MTIME)
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_ZipArchive_setMtimeIndex, 0, 2, _IS_BOOL, 0)
ZEND_ARG_TYPE_INFO(0, index, IS_LONG, 0)
ZEND_ARG_TYPE_INFO(0, timestamp, IS_LONG, 0)
@@ -150,7 +149,6 @@ ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_ZipArchive_setMt
ZEND_ARG_TYPE_INFO(0, timestamp, IS_LONG, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, flags, IS_LONG, 0, "0")
ZEND_END_ARG_INFO()
#endif
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_MASK_EX(arginfo_class_ZipArchive_getCommentIndex, 0, 1, MAY_BE_STRING|MAY_BE_FALSE)
ZEND_ARG_TYPE_INFO(0, index, IS_LONG, 0)
@@ -334,10 +332,8 @@ ZEND_METHOD(ZipArchive, setArchiveFlag);
ZEND_METHOD(ZipArchive, getArchiveFlag);
ZEND_METHOD(ZipArchive, setCommentIndex);
ZEND_METHOD(ZipArchive, setCommentName);
#if defined(HAVE_SET_MTIME)
ZEND_METHOD(ZipArchive, setMtimeIndex);
ZEND_METHOD(ZipArchive, setMtimeName);
#endif
ZEND_METHOD(ZipArchive, getCommentIndex);
ZEND_METHOD(ZipArchive, getCommentName);
ZEND_METHOD(ZipArchive, deleteIndex);
@@ -414,10 +410,8 @@ static const zend_function_entry class_ZipArchive_methods[] = {
ZEND_ME(ZipArchive, getArchiveFlag, arginfo_class_ZipArchive_getArchiveFlag, ZEND_ACC_PUBLIC)
ZEND_ME(ZipArchive, setCommentIndex, arginfo_class_ZipArchive_setCommentIndex, ZEND_ACC_PUBLIC)
ZEND_ME(ZipArchive, setCommentName, arginfo_class_ZipArchive_setCommentName, ZEND_ACC_PUBLIC)
#if defined(HAVE_SET_MTIME)
ZEND_ME(ZipArchive, setMtimeIndex, arginfo_class_ZipArchive_setMtimeIndex, ZEND_ACC_PUBLIC)
ZEND_ME(ZipArchive, setMtimeName, arginfo_class_ZipArchive_setMtimeName, ZEND_ACC_PUBLIC)
#endif
ZEND_ME(ZipArchive, getCommentIndex, arginfo_class_ZipArchive_getCommentIndex, ZEND_ACC_PUBLIC)
ZEND_ME(ZipArchive, getCommentName, arginfo_class_ZipArchive_getCommentName, ZEND_ACC_PUBLIC)
ZEND_ME(ZipArchive, deleteIndex, arginfo_class_ZipArchive_deleteIndex, ZEND_ACC_PUBLIC)

View File

@@ -2,11 +2,6 @@
setMtime
--EXTENSIONS--
zip
--SKIPIF--
<?php
/* $Id$ */
if (!method_exists('ZipArchive', 'setMtimeName')) die('skip libzip too old');
?>
--INI--
date.timezone=UTC
--FILE--

View File

@@ -49,18 +49,11 @@ static ssize_t php_zip_ops_read(php_stream *stream, char *buf, size_t count)
if (self->zf) {
n = zip_fread(self->zf, buf, count);
if (n < 0) {
#if LIBZIP_VERSION_MAJOR < 1
int ze, se;
zip_file_error_get(self->zf, &ze, &se);
stream->eof = 1;
php_error_docref(NULL, E_WARNING, "Zip stream error: %s", zip_file_strerror(self->zf));
#else
zip_error_t *err;
err = zip_file_get_error(self->zf);
stream->eof = 1;
php_error_docref(NULL, E_WARNING, "Zip stream error: %s", zip_error_strerror(err));
zip_error_fini(err);
#endif
return -1;
}
/* cast count to signed value to avoid possibly negative n