mirror of
https://github.com/php/php-src.git
synced 2025-08-19 08:49:28 +02:00
- Fix isset/empty($ZipArchive->property)
- Add test
This commit is contained in:
parent
bf94c89a8c
commit
330797ea73
2 changed files with 109 additions and 0 deletions
|
@ -449,6 +449,55 @@ static zval* php_zip_read_property(zval *object, zval *member, int type TSRMLS_D
|
|||
}
|
||||
/* }}} */
|
||||
|
||||
static int php_zip_has_property(zval *object, zval *member, int type TSRMLS_DC) /* {{{ */
|
||||
{
|
||||
ze_zip_object *obj;
|
||||
zval tmp_member;
|
||||
zip_prop_handler *hnd;
|
||||
zend_object_handlers *std_hnd;
|
||||
int ret, retval = 0;
|
||||
|
||||
if (member->type != IS_STRING) {
|
||||
tmp_member = *member;
|
||||
zval_copy_ctor(&tmp_member);
|
||||
convert_to_string(&tmp_member);
|
||||
member = &tmp_member;
|
||||
}
|
||||
|
||||
ret = FAILURE;
|
||||
obj = (ze_zip_object *)zend_objects_get_address(object TSRMLS_CC);
|
||||
|
||||
if (obj->prop_handler != NULL) {
|
||||
ret = zend_hash_find(obj->prop_handler, Z_STRVAL_P(member), Z_STRLEN_P(member)+1, (void **) &hnd);
|
||||
}
|
||||
|
||||
if (ret == SUCCESS) {
|
||||
zval *tmp;
|
||||
|
||||
if (type == 2) {
|
||||
retval = 1;
|
||||
} else if (php_zip_property_reader(obj, hnd, &tmp, 1 TSRMLS_CC) == SUCCESS) {
|
||||
tmp->refcount = 1;
|
||||
tmp->is_ref = 0;
|
||||
if (type == 1) {
|
||||
retval = zend_is_true(tmp);
|
||||
} else if (type == 0) {
|
||||
retval = (Z_TYPE_P(tmp) != IS_NULL);
|
||||
}
|
||||
zval_ptr_dtor(&tmp);
|
||||
}
|
||||
} else {
|
||||
std_hnd = zend_get_std_object_handlers();
|
||||
retval = std_hnd->has_property(object, member, type TSRMLS_CC);
|
||||
}
|
||||
|
||||
if (member == &tmp_member) {
|
||||
zval_dtor(member);
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
static HashTable *php_zip_get_properties(zval *object TSRMLS_DC)/* {{{ */
|
||||
{
|
||||
ze_zip_object *obj;
|
||||
|
@ -2059,6 +2108,7 @@ static PHP_MINIT_FUNCTION(zip)
|
|||
|
||||
zip_object_handlers.get_properties = php_zip_get_properties;
|
||||
zip_object_handlers.read_property = php_zip_read_property;
|
||||
zip_object_handlers.has_property = php_zip_has_property;
|
||||
|
||||
INIT_CLASS_ENTRY(ce, "ZipArchive", zip_class_functions);
|
||||
ce.create_object = php_zip_object_new;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue