diff --git a/php8/php_zip.c b/php8/php_zip.c index f131966..841488b 100644 --- a/php8/php_zip.c +++ b/php8/php_zip.c @@ -334,7 +334,7 @@ typedef struct { #endif } zip_options; -static int php_zip_parse_options(zval *options, zip_options *opts) +static int php_zip_parse_options(HashTable *options, zip_options *opts) /* {{{ */ { zval *option; @@ -347,23 +347,23 @@ static int php_zip_parse_options(zval *options, zip_options *opts) opts->enc_method = -1; /* -1 to not change default */ #endif - if ((option = zend_hash_str_find(Z_ARRVAL_P(options), "remove_all_path", sizeof("remove_all_path") - 1)) != NULL) { + if ((option = zend_hash_str_find(options, "remove_all_path", sizeof("remove_all_path") - 1)) != NULL) { opts->remove_all_path = zval_get_long(option); } - if ((option = zend_hash_str_find(Z_ARRVAL_P(options), "comp_method", sizeof("comp_method") - 1)) != NULL) { + if ((option = zend_hash_str_find(options, "comp_method", sizeof("comp_method") - 1)) != NULL) { opts->comp_method = zval_get_long(option); - if ((option = zend_hash_str_find(Z_ARRVAL_P(options), "comp_flags", sizeof("comp_flags") - 1)) != NULL) { + if ((option = zend_hash_str_find(options, "comp_flags", sizeof("comp_flags") - 1)) != NULL) { opts->comp_flags = zval_get_long(option); } } #ifdef HAVE_ENCRYPTION - if ((option = zend_hash_str_find(Z_ARRVAL_P(options), "enc_method", sizeof("enc_method") - 1)) != NULL) { + if ((option = zend_hash_str_find(options, "enc_method", sizeof("enc_method") - 1)) != NULL) { opts->enc_method = zval_get_long(option); - if ((option = zend_hash_str_find(Z_ARRVAL_P(options), "enc_password", sizeof("enc_password") - 1)) != NULL) { + if ((option = zend_hash_str_find(options, "enc_password", sizeof("enc_password") - 1)) != NULL) { if (Z_TYPE_P(option) != IS_STRING) { php_error_docref(NULL, E_WARNING, "enc_password option expected to be a string"); return -1; @@ -373,7 +373,7 @@ static int php_zip_parse_options(zval *options, zip_options *opts) } #endif - if ((option = zend_hash_str_find(Z_ARRVAL_P(options), "remove_path", sizeof("remove_path") - 1)) != NULL) { + if ((option = zend_hash_str_find(options, "remove_path", sizeof("remove_path") - 1)) != NULL) { if (Z_TYPE_P(option) != IS_STRING) { php_error_docref(NULL, E_WARNING, "remove_path option expected to be a string"); return -1; @@ -393,7 +393,7 @@ static int php_zip_parse_options(zval *options, zip_options *opts) opts->remove_path = Z_STRVAL_P(option); } - if ((option = zend_hash_str_find(Z_ARRVAL_P(options), "add_path", sizeof("add_path") - 1)) != NULL) { + if ((option = zend_hash_str_find(options, "add_path", sizeof("add_path") - 1)) != NULL) { if (Z_TYPE_P(option) != IS_STRING) { php_error_docref(NULL, E_WARNING, "add_path option expected to be a string"); return -1; @@ -413,7 +413,7 @@ static int php_zip_parse_options(zval *options, zip_options *opts) opts->add_path = Z_STRVAL_P(option); } - if ((option = zend_hash_str_find(Z_ARRVAL_P(options), "flags", sizeof("flags") - 1)) != NULL) { + if ((option = zend_hash_str_find(options, "flags", sizeof("flags") - 1)) != NULL) { if (Z_TYPE_P(option) != IS_LONG) { php_error_docref(NULL, E_WARNING, "flags option expected to be a integer"); return -1; @@ -1101,8 +1101,7 @@ static PHP_MSHUTDOWN_FUNCTION(zip); static PHP_MINFO_FUNCTION(zip); /* }}} */ -/* {{{ zip_module_entry - */ +/* {{{ zip_module_entry */ zend_module_entry zip_module_entry = { STANDARD_MODULE_HEADER, "zip", @@ -1122,8 +1121,7 @@ ZEND_GET_MODULE(zip) #endif /* set macro */ -/* {{{ proto resource zip_open(string filename) -Create new zip using source uri for output */ +/* {{{ Create new zip using source uri for output */ PHP_FUNCTION(zip_open) { char resolved_path[MAXPATHLEN + 1]; @@ -1163,8 +1161,7 @@ PHP_FUNCTION(zip_open) } /* }}} */ -/* {{{ proto void zip_close(resource zip) - Close a Zip archive */ +/* {{{ Close a Zip archive */ PHP_FUNCTION(zip_close) { zval * zip; @@ -1183,8 +1180,7 @@ PHP_FUNCTION(zip_close) } /* }}} */ -/* {{{ proto resource zip_read(resource zip) - Returns the next file in the archive */ +/* {{{ Returns the next file in the archive */ PHP_FUNCTION(zip_read) { zval *zip_dp; @@ -1229,8 +1225,7 @@ PHP_FUNCTION(zip_read) } /* }}} */ -/* {{{ proto bool zip_entry_open(resource zip_dp, resource zip_entry [, string mode]) - Open a Zip File, pointed by the resource entry */ +/* {{{ Open a Zip File, pointed by the resource entry */ /* Dummy function to follow the old API */ PHP_FUNCTION(zip_entry_open) { @@ -1261,8 +1256,7 @@ PHP_FUNCTION(zip_entry_open) } /* }}} */ -/* {{{ proto bool zip_entry_close(resource zip_ent) - Close a zip entry */ +/* {{{ Close a zip entry */ PHP_FUNCTION(zip_entry_close) { zval * zip_entry; @@ -1280,8 +1274,7 @@ PHP_FUNCTION(zip_entry_close) } /* }}} */ -/* {{{ proto mixed zip_entry_read(resource zip_entry [, int len]) - Read from an open directory entry */ +/* {{{ Read from an open directory entry */ PHP_FUNCTION(zip_entry_read) { zval * zip_entry; @@ -1374,40 +1367,35 @@ static void php_zip_entry_get_info(INTERNAL_FUNCTION_PARAMETERS, int opt) /* {{{ } /* }}} */ -/* {{{ proto string zip_entry_name(resource zip_entry) - Return the name given a ZZip entry */ +/* {{{ Return the name given a ZZip entry */ PHP_FUNCTION(zip_entry_name) { php_zip_entry_get_info(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0); } /* }}} */ -/* {{{ proto int zip_entry_compressedsize(resource zip_entry) - Return the compressed size of a ZZip entry */ +/* {{{ Return the compressed size of a ZZip entry */ PHP_FUNCTION(zip_entry_compressedsize) { php_zip_entry_get_info(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1); } /* }}} */ -/* {{{ proto int zip_entry_filesize(resource zip_entry) - Return the actual filesize of a ZZip entry */ +/* {{{ Return the actual filesize of a ZZip entry */ PHP_FUNCTION(zip_entry_filesize) { php_zip_entry_get_info(INTERNAL_FUNCTION_PARAM_PASSTHRU, 2); } /* }}} */ -/* {{{ proto string zip_entry_compressionmethod(resource zip_entry) - Return a string containing the compression method used on a particular entry */ +/* {{{ Return a string containing the compression method used on a particular entry */ PHP_FUNCTION(zip_entry_compressionmethod) { php_zip_entry_get_info(INTERNAL_FUNCTION_PARAM_PASSTHRU, 3); } /* }}} */ -/* {{{ proto mixed ZipArchive::open(string source [, int flags]) -Create new zip using source uri for output, return TRUE on success or the error code */ +/* {{{ Create new zip using source uri for output, return TRUE on success or the error code */ PHP_METHOD(ZipArchive, open) { struct zip *intern; @@ -1452,16 +1440,20 @@ PHP_METHOD(ZipArchive, open) ze_obj->filename = NULL; } - /* reduce BC break introduce in libzip 1.6.0 - "Do not accept empty files as valid zip archives any longer" */ - /* open for write without option to empty the archive */ +#ifdef ZIP_RDONLY if ((flags & (ZIP_TRUNCATE | ZIP_RDONLY)) == 0) { +#else + if ((flags & ZIP_TRUNCATE) == 0) { +#endif zend_stat_t st; /* 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"); + + /* reduce BC break introduced in libzip 1.6.0 + "Do not accept empty files as valid zip archives any longer" */ flags |= ZIP_TRUNCATE; } } @@ -1478,8 +1470,7 @@ PHP_METHOD(ZipArchive, open) } /* }}} */ -/* {{{ proto resource ZipArchive::setPassword(string password) -Set the password for the active archive */ +/* {{{ Set the password for the active archive */ PHP_METHOD(ZipArchive, setPassword) { struct zip *intern; @@ -1506,8 +1497,7 @@ PHP_METHOD(ZipArchive, setPassword) } /* }}} */ -/* {{{ proto bool ZipArchive::close() -close the zip archive */ +/* {{{ close the zip archive */ PHP_METHOD(ZipArchive, close) { struct zip *intern; @@ -1558,8 +1548,7 @@ PHP_METHOD(ZipArchive, close) } /* }}} */ -/* {{{ proto bool ZipArchive::count() -close the zip archive */ +/* {{{ close the zip archive */ PHP_METHOD(ZipArchive, count) { struct zip *intern; @@ -1577,8 +1566,7 @@ PHP_METHOD(ZipArchive, count) } /* }}} */ -/* {{{ proto string ZipArchive::getStatusString() - * Returns the status error message, system and/or zip messages */ +/* {{{ Returns the status error message, system and/or zip messages */ PHP_METHOD(ZipArchive, getStatusString) { zval *self = ZEND_THIS; @@ -1621,8 +1609,7 @@ PHP_METHOD(ZipArchive, getStatusString) } /* }}} */ -/* {{{ proto bool ZipArchive::addEmptyDir(string dirname [, bool flags = 0]) -Returns the index of the entry named filename in the archive */ +/* {{{ Returns the index of the entry named filename in the archive */ PHP_METHOD(ZipArchive, addEmptyDir) { struct zip *intern; @@ -1671,19 +1658,19 @@ static void php_zip_add_from_pattern(INTERNAL_FUNCTION_PARAMETERS, int type) /* char *path = "."; size_t path_len = 1; zend_long glob_flags = 0; - zval *options = NULL; + HashTable *options = NULL; zip_options opts; int found; zend_string *pattern; /* 1 == glob, 2 == pcre */ if (type == 1) { - if (zend_parse_parameters(ZEND_NUM_ARGS(), "P|la", + if (zend_parse_parameters(ZEND_NUM_ARGS(), "P|lh", &pattern, &glob_flags, &options) == FAILURE) { RETURN_THROWS(); } } else { - if (zend_parse_parameters(ZEND_NUM_ARGS(), "P|sa", + if (zend_parse_parameters(ZEND_NUM_ARGS(), "P|sh", &pattern, &path, &path_len, &options) == FAILURE) { RETURN_THROWS(); } @@ -1693,7 +1680,7 @@ static void php_zip_add_from_pattern(INTERNAL_FUNCTION_PARAMETERS, int type) /* php_error_docref(NULL, E_NOTICE, "Empty string as pattern"); RETURN_FALSE; } - if (options && zend_hash_num_elements(Z_ARRVAL_P(options)) > 0 && (php_zip_parse_options(options, &opts) < 0)) { + if (options && zend_hash_num_elements(options) > 0 && (php_zip_parse_options(options, &opts) < 0)) { RETURN_FALSE; } @@ -1778,24 +1765,21 @@ static void php_zip_add_from_pattern(INTERNAL_FUNCTION_PARAMETERS, int type) /* } /* }}} */ -/* {{{ proto bool ZipArchive::addGlob(string pattern[,int flags [, array options]]) -Add files matching the glob pattern. See php's glob for the pattern syntax. */ +/* {{{ Add files matching the glob pattern. See php's glob for the pattern syntax. */ PHP_METHOD(ZipArchive, addGlob) { php_zip_add_from_pattern(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1); } /* }}} */ -/* {{{ proto bool ZipArchive::addPattern(string pattern[, string path [, array options]]) -Add files matching the pcre pattern. See php's pcre for the pattern syntax. */ +/* {{{ Add files matching the pcre pattern. See php's pcre for the pattern syntax. */ PHP_METHOD(ZipArchive, addPattern) { php_zip_add_from_pattern(INTERNAL_FUNCTION_PARAM_PASSTHRU, 2); } /* }}} */ -/* {{{ proto bool ZipArchive::addFile(string filepath[, string entryname[, int start [, int length [, int flags = FL_OVERWRITE]]]]) -Add a file in a Zip archive using its path and the name to use. */ +/* {{{ Add a file in a Zip archive using its path and the name to use. */ PHP_METHOD(ZipArchive, addFile) { zval *self = ZEND_THIS; @@ -1829,8 +1813,7 @@ PHP_METHOD(ZipArchive, addFile) } /* }}} */ -/* {{{ proto bool ZipArchive::replaceFile(string filepath, int index[, int start [, int length [, int flags = 0]]]) -Add a file in a Zip archive using its path and the name to use. */ +/* {{{ Add a file in a Zip archive using its path and the name to use. */ PHP_METHOD(ZipArchive, replaceFile) { zval *self = ZEND_THIS; @@ -1863,8 +1846,7 @@ PHP_METHOD(ZipArchive, replaceFile) } /* }}} */ -/* {{{ proto bool ZipArchive::addFromString(string name, string content [, int flags = FL_OVERWRITE]) -Add a file using content and the entry name */ +/* {{{ Add a file using content and the entry name */ PHP_METHOD(ZipArchive, addFromString) { struct zip *intern; @@ -1913,8 +1895,7 @@ PHP_METHOD(ZipArchive, addFromString) } /* }}} */ -/* {{{ proto array ZipArchive::statName(string filename[, int flags]) -Returns the information about a the zip entry filename */ +/* {{{ Returns the information about a the zip entry filename */ PHP_METHOD(ZipArchive, statName) { struct zip *intern; @@ -1935,8 +1916,7 @@ PHP_METHOD(ZipArchive, statName) } /* }}} */ -/* {{{ proto resource ZipArchive::statIndex(int index[, int flags]) -Returns the zip entry information using its index */ +/* {{{ Returns the zip entry information using its index */ PHP_METHOD(ZipArchive, statIndex) { struct zip *intern; @@ -1959,8 +1939,7 @@ PHP_METHOD(ZipArchive, statIndex) } /* }}} */ -/* {{{ proto int ZipArchive::locateName(string filename[, int flags]) -Returns the index of the entry named filename in the archive */ +/* {{{ Returns the index of the entry named filename in the archive */ PHP_METHOD(ZipArchive, locateName) { struct zip *intern; @@ -1989,8 +1968,7 @@ PHP_METHOD(ZipArchive, locateName) } /* }}} */ -/* {{{ proto string ZipArchive::getNameIndex(int index [, int flags]) -Returns the name of the file at position index */ +/* {{{ Returns the name of the file at position index */ PHP_METHOD(ZipArchive, getNameIndex) { struct zip *intern; @@ -2015,8 +1993,7 @@ PHP_METHOD(ZipArchive, getNameIndex) } /* }}} */ -/* {{{ proto bool ZipArchive::setArchiveComment(string comment) -Set or remove (NULL/'') the comment of the archive */ +/* {{{ Set or remove (NULL/'') the comment of the archive */ PHP_METHOD(ZipArchive, setArchiveComment) { struct zip *intern; @@ -2043,8 +2020,7 @@ PHP_METHOD(ZipArchive, setArchiveComment) } /* }}} */ -/* {{{ proto string ZipArchive::getArchiveComment([int flags]) -Returns the comment of an entry using its index */ +/* {{{ Returns the comment of an entry using its index */ PHP_METHOD(ZipArchive, getArchiveComment) { struct zip *intern; @@ -2067,8 +2043,7 @@ PHP_METHOD(ZipArchive, getArchiveComment) } /* }}} */ -/* {{{ proto bool ZipArchive::setCommentName(string name, string comment) -Set or remove (NULL/'') the comment of an entry using its Name */ +/* {{{ Set or remove (NULL/'') the comment of an entry using its Name */ PHP_METHOD(ZipArchive, setCommentName) { struct zip *intern; @@ -2101,8 +2076,7 @@ PHP_METHOD(ZipArchive, setCommentName) } /* }}} */ -/* {{{ proto bool ZipArchive::setCommentIndex(int index, string comment) -Set or remove (NULL/'') the comment of an entry using its index */ +/* {{{ Set or remove (NULL/'') the comment of an entry using its index */ PHP_METHOD(ZipArchive, setCommentIndex) { struct zip *intern; @@ -2132,8 +2106,7 @@ PHP_METHOD(ZipArchive, setCommentIndex) /* those constants/functions are only available in libzip since 0.11.2 */ #ifdef ZIP_OPSYS_DEFAULT -/* {{{ proto bool ZipArchive::setExternalAttributesName(string name, int opsys, int attr [, int flags]) -Set external attributes for file in zip, using its name */ +/* {{{ Set external attributes for file in zip, using its name */ PHP_METHOD(ZipArchive, setExternalAttributesName) { struct zip *intern; @@ -2166,8 +2139,7 @@ PHP_METHOD(ZipArchive, setExternalAttributesName) } /* }}} */ -/* {{{ proto bool ZipArchive::setExternalAttributesIndex(int index, int opsys, int attr [, int flags]) -Set external attributes for file in zip, using its index */ +/* {{{ Set external attributes for file in zip, using its index */ PHP_METHOD(ZipArchive, setExternalAttributesIndex) { struct zip *intern; @@ -2191,8 +2163,7 @@ PHP_METHOD(ZipArchive, setExternalAttributesIndex) } /* }}} */ -/* {{{ proto bool ZipArchive::getExternalAttributesName(string name, int &opsys, int &attr [, int flags]) -Get external attributes for file in zip, using its name */ +/* {{{ Get external attributes for file in zip, using its name */ PHP_METHOD(ZipArchive, getExternalAttributesName) { struct zip *intern; @@ -2229,8 +2200,7 @@ PHP_METHOD(ZipArchive, getExternalAttributesName) } /* }}} */ -/* {{{ proto bool ZipArchive::getExternalAttributesIndex(int index, int &opsys, int &attr [, int flags]) -Get external attributes for file in zip, using its index */ +/* {{{ Get external attributes for file in zip, using its index */ PHP_METHOD(ZipArchive, getExternalAttributesIndex) { struct zip *intern; @@ -2260,8 +2230,7 @@ PHP_METHOD(ZipArchive, getExternalAttributesIndex) #endif /* ifdef ZIP_OPSYS_DEFAULT */ #ifdef HAVE_ENCRYPTION -/* {{{ proto bool ZipArchive::setEncryptionName(string name, int method, [string password]) -Set encryption method for file in zip, using its name */ +/* {{{ Set encryption method for file in zip, using its name */ PHP_METHOD(ZipArchive, setEncryptionName) { struct zip *intern; @@ -2294,8 +2263,7 @@ PHP_METHOD(ZipArchive, setEncryptionName) } /* }}} */ -/* {{{ proto bool ZipArchive::setEncryptionIndex(int index, int method, [string password]) -Set encryption method for file in zip, using its index */ +/* {{{ Set encryption method for file in zip, using its index */ PHP_METHOD(ZipArchive, setEncryptionIndex) { struct zip *intern; @@ -2319,8 +2287,7 @@ PHP_METHOD(ZipArchive, setEncryptionIndex) /* }}} */ #endif -/* {{{ proto string ZipArchive::getCommentName(string name[, int flags]) -Returns the comment of an entry using its name */ +/* {{{ Returns the comment of an entry using its name */ PHP_METHOD(ZipArchive, getCommentName) { struct zip *intern; @@ -2354,8 +2321,7 @@ PHP_METHOD(ZipArchive, getCommentName) } /* }}} */ -/* {{{ proto string ZipArchive::getCommentIndex(int index[, int flags]) -Returns the comment of an entry using its index */ +/* {{{ Returns the comment of an entry using its index */ PHP_METHOD(ZipArchive, getCommentIndex) { struct zip *intern; @@ -2378,8 +2344,7 @@ PHP_METHOD(ZipArchive, getCommentIndex) } /* }}} */ -/* {{{ proto bool ZipArchive::setCompressionName(string name, int comp_method[, int comp_flags]) -Set the compression of a file in zip, using its name */ +/* {{{ Set the compression of a file in zip, using its name */ PHP_METHOD(ZipArchive, setCompressionName) { struct zip *intern; @@ -2413,8 +2378,7 @@ PHP_METHOD(ZipArchive, setCompressionName) } /* }}} */ -/* {{{ proto bool ZipArchive::setCompressionIndex(int index, int comp_method[, int comp_flags]) -Set the compression of a file in zip, using its index */ +/* {{{ Set the compression of a file in zip, using its index */ PHP_METHOD(ZipArchive, setCompressionIndex) { struct zip *intern; @@ -2438,8 +2402,7 @@ PHP_METHOD(ZipArchive, setCompressionIndex) /* }}} */ #ifdef HAVE_SET_MTIME -/* {{{ proto bool ZipArchive::setMtimeName(string name, int timestamp[, int flags]) -Set the modification time of a file in zip, using its name */ +/* {{{ Set the modification time of a file in zip, using its name */ PHP_METHOD(ZipArchive, setMtimeName) { struct zip *intern; @@ -2473,8 +2436,7 @@ PHP_METHOD(ZipArchive, setMtimeName) } /* }}} */ -/* {{{ proto bool ZipArchive::setMtimeIndex(int index, int timestamp[, int flags]) -Set the modification time of a file in zip, using its index */ +/* {{{ Set the modification time of a file in zip, using its index */ PHP_METHOD(ZipArchive, setMtimeIndex) { struct zip *intern; @@ -2498,8 +2460,7 @@ PHP_METHOD(ZipArchive, setMtimeIndex) /* }}} */ #endif -/* {{{ proto bool ZipArchive::deleteIndex(int index) -Delete a file using its index */ +/* {{{ Delete a file using its index */ PHP_METHOD(ZipArchive, deleteIndex) { struct zip *intern; @@ -2524,8 +2485,7 @@ PHP_METHOD(ZipArchive, deleteIndex) } /* }}} */ -/* {{{ proto bool ZipArchive::deleteName(string name) -Delete a file using its index */ +/* {{{ Delete a file using its index */ PHP_METHOD(ZipArchive, deleteName) { struct zip *intern; @@ -2552,8 +2512,7 @@ PHP_METHOD(ZipArchive, deleteName) } /* }}} */ -/* {{{ proto bool ZipArchive::renameIndex(int index, string new_name) -Rename an entry selected by its index to new_name */ +/* {{{ Rename an entry selected by its index to new_name */ PHP_METHOD(ZipArchive, renameIndex) { struct zip *intern; @@ -2585,8 +2544,7 @@ PHP_METHOD(ZipArchive, renameIndex) } /* }}} */ -/* {{{ proto bool ZipArchive::renameName(string name, string new_name) -Rename an entry selected by its name to new_name */ +/* {{{ Rename an entry selected by its name to new_name */ PHP_METHOD(ZipArchive, renameName) { struct zip *intern; @@ -2616,8 +2574,7 @@ PHP_METHOD(ZipArchive, renameName) } /* }}} */ -/* {{{ proto bool ZipArchive::unchangeIndex(int index) -Changes to the file at position index are reverted */ +/* {{{ Changes to the file at position index are reverted */ PHP_METHOD(ZipArchive, unchangeIndex) { struct zip *intern; @@ -2642,8 +2599,7 @@ PHP_METHOD(ZipArchive, unchangeIndex) } /* }}} */ -/* {{{ proto bool ZipArchive::unchangeName(string name) -Changes to the file named 'name' are reverted */ +/* {{{ Changes to the file named 'name' are reverted */ PHP_METHOD(ZipArchive, unchangeName) { struct zip *intern; @@ -2672,8 +2628,7 @@ PHP_METHOD(ZipArchive, unchangeName) } /* }}} */ -/* {{{ proto bool ZipArchive::unchangeAll() -All changes to files and global information in archive are reverted */ +/* {{{ All changes to files and global information in archive are reverted */ PHP_METHOD(ZipArchive, unchangeAll) { struct zip *intern; @@ -2693,8 +2648,7 @@ PHP_METHOD(ZipArchive, unchangeAll) } /* }}} */ -/* {{{ proto bool ZipArchive::unchangeArchive() -Revert all global changes to the archive archive. For now, this only reverts archive comment changes. */ +/* {{{ Revert all global changes to the archive archive. For now, this only reverts archive comment changes. */ PHP_METHOD(ZipArchive, unchangeArchive) { struct zip *intern; @@ -2714,8 +2668,7 @@ PHP_METHOD(ZipArchive, unchangeArchive) } /* }}} */ -/* {{{ proto bool ZipArchive::extractTo(string pathto[, mixed files]) -Extract one or more file from a zip archive */ +/* {{{ Extract one or more file from a zip archive */ /* TODO: * - allow index or array of indices * - replace path @@ -2868,24 +2821,21 @@ static void php_zip_get_from(INTERNAL_FUNCTION_PARAMETERS, int type) /* {{{ */ } /* }}} */ -/* {{{ proto string ZipArchive::getFromName(string entryname[, int len [, int flags]]) -get the contents of an entry using its name */ +/* {{{ get the contents of an entry using its name */ PHP_METHOD(ZipArchive, getFromName) { php_zip_get_from(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1); } /* }}} */ -/* {{{ proto string ZipArchive::getFromIndex(int index[, int len [, int flags]]) -get the contents of an entry using its index */ +/* {{{ get the contents of an entry using its index */ PHP_METHOD(ZipArchive, getFromIndex) { php_zip_get_from(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0); } /* }}} */ -/* {{{ proto resource ZipArchive::getStream(string entryname) -get a stream for an entry using its name */ +/* {{{ get a stream for an entry using its name */ PHP_METHOD(ZipArchive, getStream) { struct zip *intern; @@ -2925,13 +2875,12 @@ static void _php_zip_progress_callback(zip_t *arch, double state, void *ptr) ze_zip_object *obj = ptr; ZVAL_DOUBLE(&cb_args[0], state); - if (call_user_function_ex(EG(function_table), NULL, &obj->progress_callback, &cb_retval, 1, cb_args, 0, NULL) == SUCCESS && !Z_ISUNDEF(cb_retval)) { + if (call_user_function(EG(function_table), NULL, &obj->progress_callback, &cb_retval, 1, cb_args) == SUCCESS && !Z_ISUNDEF(cb_retval)) { zval_ptr_dtor(&cb_retval); } } -/* {{{ proto bool ZipArchive::registerProgressCallback(double rate, callable callback) -register a progression callback: void callback(double state); */ +/* {{{ register a progression callback: void callback(double state); */ PHP_METHOD(ZipArchive, registerProgressCallback) { struct zip *intern; @@ -2981,7 +2930,7 @@ static int _php_zip_cancel_callback(zip_t *arch, void *ptr) int retval = 0; ze_zip_object *obj = ptr; - if (call_user_function_ex(EG(function_table), NULL, &obj->cancel_callback, &cb_retval, 0, NULL, 0, NULL) == SUCCESS && !Z_ISUNDEF(cb_retval)) { + if (call_user_function(EG(function_table), NULL, &obj->cancel_callback, &cb_retval, 0, NULL) == SUCCESS && !Z_ISUNDEF(cb_retval)) { retval = zval_get_long(&cb_retval); zval_ptr_dtor(&cb_retval); } @@ -2989,8 +2938,7 @@ static int _php_zip_cancel_callback(zip_t *arch, void *ptr) return retval; } -/* {{{ proto bool ZipArchive::registerCancelCallback(callable callback) -register a progression callback: int callback(double state); */ +/* {{{ register a progression callback: int callback(double state); */ PHP_METHOD(ZipArchive, registerCancelCallback) { struct zip *intern; @@ -3033,8 +2981,7 @@ PHP_METHOD(ZipArchive, registerCancelCallback) #endif #ifdef HAVE_METHOD_SUPPORTED -/* {{{ proto bool ZipArchive::isCompressionMethodSupported(int method, bool enc) -check if a compression method is available in used libzip */ +/* {{{ check if a compression method is available in used libzip */ PHP_METHOD(ZipArchive, isCompressionMethodSupported) { zend_long method; @@ -3047,8 +2994,7 @@ PHP_METHOD(ZipArchive, isCompressionMethodSupported) } /* }}} */ -/* {{{ proto bool ZipArchive::isEncryptionMethodSupported(int method, bool enc) -check if a encryption method is available in used libzip */ +/* {{{ check if a encryption method is available in used libzip */ PHP_METHOD(ZipArchive, isEncryptionMethodSupported) { zend_long method; @@ -3136,6 +3082,9 @@ static PHP_MINIT_FUNCTION(zip) #ifdef ZIP_CM_LZMA2 REGISTER_ZIP_CLASS_CONST_LONG("CM_LZMA2", ZIP_CM_LZMA2); #endif +#ifdef ZIP_CM_ZSTD + REGISTER_ZIP_CLASS_CONST_LONG("CM_ZSTD", ZIP_CM_ZSTD); +#endif #ifdef ZIP_CM_XZ REGISTER_ZIP_CLASS_CONST_LONG("CM_XZ", ZIP_CM_XZ); #endif @@ -3240,8 +3189,7 @@ static PHP_MINIT_FUNCTION(zip) } /* }}} */ -/* {{{ PHP_MSHUTDOWN_FUNCTION - */ +/* {{{ PHP_MSHUTDOWN_FUNCTION */ static PHP_MSHUTDOWN_FUNCTION(zip) { zend_hash_destroy(&zip_prop_handlers); @@ -3250,8 +3198,7 @@ static PHP_MSHUTDOWN_FUNCTION(zip) } /* }}} */ -/* {{{ PHP_MINFO_FUNCTION - */ +/* {{{ PHP_MINFO_FUNCTION */ static PHP_MINFO_FUNCTION(zip) { php_info_print_table_start(); diff --git a/php8/php_zip.stub.php b/php8/php_zip.stub.php index da8e373..4d9ba27 100644 --- a/php8/php_zip.stub.php +++ b/php8/php_zip.stub.php @@ -2,44 +2,66 @@ /** @generate-function-entries */ -/** @return resource|int|false */ +/** + * @return resource|int|false + * @deprecated + */ function zip_open(string $filename) {} /** * @param resource $zip + * @deprecated */ function zip_close($zip): void {} /** * @param resource $zip * @return resource|false + * @deprecated */ function zip_read($zip) {} /** * @param resource $zip_dp * @param resource $zip_entry + * @deprecated */ function zip_entry_open($zip_dp, $zip_entry, string $mode = 'rb'): bool {} /** * @param resource $zip_ent + * @deprecated */ function zip_entry_close($zip_ent): bool {} -/** @param resource $zip_entry */ +/** + * @param resource $zip_entry + * @deprecated + */ function zip_entry_read($zip_entry, int $len = 1024): string|false {} -/** @param resource $zip_entry */ +/** + * @param resource $zip_entry + * @deprecated + */ function zip_entry_name($zip_entry): string|false {} -/** @param resource $zip_entry */ +/** + * @param resource $zip_entry + * @deprecated + */ function zip_entry_compressedsize($zip_entry): int|false {} -/** @param resource $zip_entry */ +/** + * @param resource $zip_entry + * @deprecated + */ function zip_entry_filesize($zip_entry): int|false {} -/** @param resource $zip_entry */ +/** + * @param resource $zip_entry + * @deprecated + */ function zip_entry_compressionmethod($zip_entry): string|false {} class ZipArchive @@ -194,9 +216,9 @@ class ZipArchive #ifdef HAVE_METHOD_SUPPORTED /** @return bool */ - public static function isCompressionMethodSupported(int $method, bool $enc): bool {} + public static function isCompressionMethodSupported(int $method, bool $enc = true): bool {} /** @return bool */ - public static function isEncryptionMethodSupported(int $method, bool $enc): bool {} + public static function isEncryptionMethodSupported(int $method, bool $enc = true): bool {} #endif } diff --git a/php8/php_zip_arginfo.h b/php8/php_zip_arginfo.h index c1e8f24..25157d8 100644 --- a/php8/php_zip_arginfo.h +++ b/php8/php_zip_arginfo.h @@ -1,4 +1,5 @@ -/* This is a generated file, edit the .stub.php file instead. */ +/* This is a generated file, edit the .stub.php file instead. + * Stub hash: 95608dd1d6c2ad80ada990a9e939b76dba705d48 */ ZEND_BEGIN_ARG_INFO_EX(arginfo_zip_open, 0, 0, 1) ZEND_ARG_TYPE_INFO(0, filename, IS_STRING, 0) @@ -271,9 +272,9 @@ ZEND_END_ARG_INFO() #endif #if defined(HAVE_METHOD_SUPPORTED) -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_ZipArchive_isCompressionMethodSupported, 0, 2, _IS_BOOL, 0) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_ZipArchive_isCompressionMethodSupported, 0, 1, _IS_BOOL, 0) ZEND_ARG_TYPE_INFO(0, method, IS_LONG, 0) - ZEND_ARG_TYPE_INFO(0, enc, _IS_BOOL, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, enc, _IS_BOOL, 0, "true") ZEND_END_ARG_INFO() #endif @@ -366,16 +367,16 @@ ZEND_METHOD(ZipArchive, isEncryptionMethodSupported); static const zend_function_entry ext_functions[] = { - ZEND_FE(zip_open, arginfo_zip_open) - ZEND_FE(zip_close, arginfo_zip_close) - ZEND_FE(zip_read, arginfo_zip_read) - ZEND_FE(zip_entry_open, arginfo_zip_entry_open) - ZEND_FE(zip_entry_close, arginfo_zip_entry_close) - ZEND_FE(zip_entry_read, arginfo_zip_entry_read) - ZEND_FE(zip_entry_name, arginfo_zip_entry_name) - ZEND_FE(zip_entry_compressedsize, arginfo_zip_entry_compressedsize) - ZEND_FE(zip_entry_filesize, arginfo_zip_entry_filesize) - ZEND_FE(zip_entry_compressionmethod, arginfo_zip_entry_compressionmethod) + ZEND_DEP_FE(zip_open, arginfo_zip_open) + ZEND_DEP_FE(zip_close, arginfo_zip_close) + ZEND_DEP_FE(zip_read, arginfo_zip_read) + ZEND_DEP_FE(zip_entry_open, arginfo_zip_entry_open) + ZEND_DEP_FE(zip_entry_close, arginfo_zip_entry_close) + ZEND_DEP_FE(zip_entry_read, arginfo_zip_entry_read) + ZEND_DEP_FE(zip_entry_name, arginfo_zip_entry_name) + ZEND_DEP_FE(zip_entry_compressedsize, arginfo_zip_entry_compressedsize) + ZEND_DEP_FE(zip_entry_filesize, arginfo_zip_entry_filesize) + ZEND_DEP_FE(zip_entry_compressionmethod, arginfo_zip_entry_compressionmethod) ZEND_FE_END }; diff --git a/tests/bug53885.phpt b/tests/bug53885.phpt index 602eae8..fecbf55 100644 --- a/tests/bug53885.phpt +++ b/tests/bug53885.phpt @@ -3,6 +3,7 @@ Bug #53885 (ZipArchive segfault with FL_UNCHANGED on empty archive) --SKIPIF-- = 80000) die('skip only for PHP < 8'); ?> --FILE-- open($fname); +$nx->open($fname); $nx->locateName("a",ZIPARCHIVE::FL_UNCHANGED); $nx->statName("a",ZIPARCHIVE::FL_UNCHANGED); ?> diff --git a/tests/bug53885_php8.phpt b/tests/bug53885_php8.phpt new file mode 100644 index 0000000..19fb350 --- /dev/null +++ b/tests/bug53885_php8.phpt @@ -0,0 +1,26 @@ +--TEST-- +Bug #53885 (ZipArchive segfault with FL_UNCHANGED on empty archive) +--SKIPIF-- + +--FILE-- +open($fname); +$nx->locateName("a",ZIPARCHIVE::FL_UNCHANGED); +$nx->statName("a",ZIPARCHIVE::FL_UNCHANGED); +?> +==DONE== +--CLEAN-- + +--EXPECTF-- +Deprecated: ZipArchive::open(): Using empty file as ZipArchive is deprecated in %s +==DONE== diff --git a/tests/bug7214.phpt b/tests/bug7214.phpt index f791b79..d5c7f3e 100644 --- a/tests/bug7214.phpt +++ b/tests/bug7214.phpt @@ -5,6 +5,8 @@ Bug #7214 (zip_entry_read() binary safe) /* $Id$ */ if(!extension_loaded('zip')) die('skip'); ?> +--INI-- +error_reporting=24575 --FILE-- +--INI-- +error_reporting=24575 --FILE-- +--INI-- +error_reporting=24575 --FILE-- +--INI-- +error_reporting=24575 --FILE-- +--INI-- +error_reporting=24575 --FILE-- +--INI-- +error_reporting=24575 --FILE-- +--INI-- +error_reporting=24575 --FILE-- +--INI-- +error_reporting=24575 --FILE-- +--INI-- +error_reporting=24575 --FILE-- +--INI-- +error_reporting=24575 --FILE-- +--INI-- +error_reporting=24575 --FILE-- +--INI-- +error_reporting=24575 --FILE-- +--INI-- +error_reporting=24575 --FILE--