php_zip
php_zip copied to clipboard
Inconsistent error reporting in ZipArchive::extractTo()
According to ZipArchive::extractTo documentation method "Returns true on success or false on failure". In some cases I get ValueError instead of false.
This was behavior introduced in PHP 8:
#define ZIP_FROM_OBJECT(intern, object) \
{ \
ze_zip_object *obj = Z_ZIP_P(object); \
intern = obj->za; \
if (!intern) { \
zend_value_error("Invalid or uninitialized Zip object"); \
RETURN_THROWS(); \
} \
}
/* }}} */
While it still returns false in PHP 7:
/* {{{ ZIP_FROM_OBJECT */
#define ZIP_FROM_OBJECT(intern, object) \
{ \
ze_zip_object *obj = Z_ZIP_P(object); \
intern = obj->za; \
if (!intern) { \
php_error_docref(NULL, E_WARNING, "Invalid or uninitialized Zip object"); \
RETURN_FALSE; \
} \
}
/* }}} */
I'm not sure if this a documentation or code issue.
Warning promoted to exception is a general PHP 8 feature, not specific to this extension.