summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXinchen Hui <laruence@php.net>2012-03-11 08:27:55 +0000
committerXinchen Hui <laruence@php.net>2012-03-11 08:27:55 +0000
commite6ec1fb166bfb22969ed28746b8f952dce05673e (patch)
treef2650e6e20ecadd2266f73bc7ab7f39a398121c6
parent23e65a9dcc71cf11ee5ec82c256588626545d4db (diff)
downloadphp-git-e6ec1fb166bfb22969ed28746b8f952dce05673e.tar.gz
Fixed bug #61347 (inconsist isset behavior of Arrayobject)
-rwxr-xr-xext/spl/spl_array.c73
-rw-r--r--ext/spl/tests/bug61347.phpt40
2 files changed, 75 insertions, 38 deletions
diff --git a/ext/spl/spl_array.c b/ext/spl/spl_array.c
index 5bbc41d9bb..811a30b3d4 100755
--- a/ext/spl/spl_array.c
+++ b/ext/spl/spl_array.c
@@ -601,49 +601,46 @@ static int spl_array_has_dimension_ex(int check_inherited, zval *object, zval *o
}
switch(Z_TYPE_P(offset)) {
- 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) {
- switch (check_empty) {
- case 0:
- return Z_TYPE_PP(tmp) != IS_NULL;
- case 2:
- return 1;
- default:
- return zend_is_true(*tmp);
+ case IS_STRING:
+ {
+ HashTable *ht = spl_array_get_hash_table(intern, 0 TSRMLS_CC);
+ if (zend_symtable_find(ht, Z_STRVAL_P(offset), Z_STRLEN_P(offset)+1, (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;
- } else {
- return zend_symtable_exists(spl_array_get_hash_table(intern, 0 TSRMLS_CC), Z_STRVAL_P(offset), Z_STRLEN_P(offset)+1);
- }
- case IS_DOUBLE:
- case IS_RESOURCE:
- case IS_BOOL:
- case IS_LONG:
- if (offset->type == IS_DOUBLE) {
- index = (long)Z_DVAL_P(offset);
- } else {
- 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);
+ case IS_DOUBLE:
+ case IS_RESOURCE:
+ case IS_BOOL:
+ case IS_LONG:
+ {
+ HashTable *ht = spl_array_get_hash_table(intern, 0 TSRMLS_CC);
+ if (offset->type == IS_DOUBLE) {
+ index = (long)Z_DVAL_P(offset);
+ } else {
+ index = Z_LVAL_P(offset);
+ }
+ 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;
- } else {
- return zend_hash_index_exists(spl_array_get_hash_table(intern, 0 TSRMLS_CC), index);
- }
- default:
- zend_error(E_WARNING, "Illegal offset type");
+ default:
+ zend_error(E_WARNING, "Illegal offset type");
}
return 0;
} /* }}} */
diff --git a/ext/spl/tests/bug61347.phpt b/ext/spl/tests/bug61347.phpt
new file mode 100644
index 0000000000..cb091858ae
--- /dev/null
+++ b/ext/spl/tests/bug61347.phpt
@@ -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)