mirror of
https://github.com/php/php-src.git
synced 2025-08-18 23:18:56 +02:00
Fixed bug #61347 (inconsist isset behavior of Arrayobject)
This commit is contained in:
parent
23e65a9dcc
commit
e6ec1fb166
2 changed files with 75 additions and 38 deletions
|
@ -601,49 +601,46 @@ static int spl_array_has_dimension_ex(int check_inherited, zval *object, zval *o
|
||||||
}
|
}
|
||||||
|
|
||||||
switch(Z_TYPE_P(offset)) {
|
switch(Z_TYPE_P(offset)) {
|
||||||
case IS_STRING:
|
case IS_STRING:
|
||||||
if (check_empty) {
|
{
|
||||||
if (zend_symtable_find(spl_array_get_hash_table(intern, 0 TSRMLS_CC), Z_STRVAL_P(offset), Z_STRLEN_P(offset)+1, (void **) &tmp) != FAILURE) {
|
HashTable *ht = spl_array_get_hash_table(intern, 0 TSRMLS_CC);
|
||||||
switch (check_empty) {
|
if (zend_symtable_find(ht, Z_STRVAL_P(offset), Z_STRLEN_P(offset)+1, (void **) &tmp) != FAILURE) {
|
||||||
case 0:
|
switch (check_empty) {
|
||||||
return Z_TYPE_PP(tmp) != IS_NULL;
|
case 0:
|
||||||
case 2:
|
return Z_TYPE_PP(tmp) != IS_NULL;
|
||||||
return 1;
|
case 2:
|
||||||
default:
|
return 1;
|
||||||
return zend_is_true(*tmp);
|
default:
|
||||||
|
return zend_is_true(*tmp);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
case IS_DOUBLE:
|
||||||
return zend_symtable_exists(spl_array_get_hash_table(intern, 0 TSRMLS_CC), Z_STRVAL_P(offset), Z_STRLEN_P(offset)+1);
|
case IS_RESOURCE:
|
||||||
}
|
case IS_BOOL:
|
||||||
case IS_DOUBLE:
|
case IS_LONG:
|
||||||
case IS_RESOURCE:
|
{
|
||||||
case IS_BOOL:
|
HashTable *ht = spl_array_get_hash_table(intern, 0 TSRMLS_CC);
|
||||||
case IS_LONG:
|
if (offset->type == IS_DOUBLE) {
|
||||||
if (offset->type == IS_DOUBLE) {
|
index = (long)Z_DVAL_P(offset);
|
||||||
index = (long)Z_DVAL_P(offset);
|
} else {
|
||||||
} else {
|
index = Z_LVAL_P(offset);
|
||||||
index = Z_LVAL_P(offset);
|
|
||||||
}
|
|
||||||
if (check_empty) {
|
|
||||||
HashTable *ht = spl_array_get_hash_table(intern, 0 TSRMLS_CC);
|
|
||||||
if (zend_hash_index_find(ht, index, (void **)&tmp) != FAILURE) {
|
|
||||||
switch (check_empty) {
|
|
||||||
case 0:
|
|
||||||
return Z_TYPE_PP(tmp) != IS_NULL;
|
|
||||||
case 2:
|
|
||||||
return 1;
|
|
||||||
default:
|
|
||||||
return zend_is_true(*tmp);
|
|
||||||
}
|
}
|
||||||
|
if (zend_hash_index_find(ht, index, (void **)&tmp) != FAILURE) {
|
||||||
|
switch (check_empty) {
|
||||||
|
case 0:
|
||||||
|
return Z_TYPE_PP(tmp) != IS_NULL;
|
||||||
|
case 2:
|
||||||
|
return 1;
|
||||||
|
default:
|
||||||
|
return zend_is_true(*tmp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
return 0;
|
default:
|
||||||
} else {
|
zend_error(E_WARNING, "Illegal offset type");
|
||||||
return zend_hash_index_exists(spl_array_get_hash_table(intern, 0 TSRMLS_CC), index);
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
zend_error(E_WARNING, "Illegal offset type");
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
40
ext/spl/tests/bug61347.phpt
Normal file
40
ext/spl/tests/bug61347.phpt
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
--TEST--
|
||||||
|
Bug #61347 (inconsist isset behavior of Arrayobject)
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
$a = array('b' => NULL, 37 => NULL);
|
||||||
|
var_dump(isset($a['b'])); //false
|
||||||
|
|
||||||
|
$b = new ArrayObject($a);
|
||||||
|
var_dump(isset($b['b'])); //false
|
||||||
|
var_dump(isset($b[37])); //false
|
||||||
|
var_dump(isset($b['no_exists'])); //false
|
||||||
|
var_dump(empty($b['b'])); //true
|
||||||
|
var_dump(empty($b[37])); //true
|
||||||
|
|
||||||
|
var_dump(array_key_exists('b', $b)); //true
|
||||||
|
var_dump($b['b']);
|
||||||
|
|
||||||
|
$a = array('b' => '', 37 => false);
|
||||||
|
$b = new ArrayObject($a);
|
||||||
|
var_dump(isset($b['b'])); //true
|
||||||
|
var_dump(isset($b[37])); //true
|
||||||
|
var_dump(isset($b['no_exists'])); //false
|
||||||
|
var_dump(empty($b['b'])); //true
|
||||||
|
var_dump(empty($b[37])); //true
|
||||||
|
|
||||||
|
|
||||||
|
--EXPECT--
|
||||||
|
bool(false)
|
||||||
|
bool(false)
|
||||||
|
bool(false)
|
||||||
|
bool(false)
|
||||||
|
bool(true)
|
||||||
|
bool(true)
|
||||||
|
bool(true)
|
||||||
|
NULL
|
||||||
|
bool(true)
|
||||||
|
bool(true)
|
||||||
|
bool(false)
|
||||||
|
bool(true)
|
||||||
|
bool(true)
|
Loading…
Add table
Add a link
Reference in a new issue