summaryrefslogtreecommitdiff
path: root/ext/spl
diff options
context:
space:
mode:
authorFelipe Pena <felipe@php.net>2010-12-10 23:58:33 +0000
committerFelipe Pena <felipe@php.net>2010-12-10 23:58:33 +0000
commit13c99651fc7bbcc7199e1e449d9e158752caf6ce (patch)
tree17e6c5221df246bd3fd596306022f9696da1a416 /ext/spl
parent3c8bc996dfebb72ea9e30d9ea1904724d849f58b (diff)
downloadphp-git-13c99651fc7bbcc7199e1e449d9e158752caf6ce.tar.gz
- Fixed bug #53515 (property_exists incorrect on ArrayObject null and 0 values)
Diffstat (limited to 'ext/spl')
-rwxr-xr-xext/spl/spl_array.c22
-rw-r--r--ext/spl/tests/bug53515.phpt27
2 files changed, 45 insertions, 4 deletions
diff --git a/ext/spl/spl_array.c b/ext/spl/spl_array.c
index 22b105b09e..e060baf674 100755
--- a/ext/spl/spl_array.c
+++ b/ext/spl/spl_array.c
@@ -569,8 +569,15 @@ 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 && zend_is_true(*tmp)) {
- return 1;
+ 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);
+ }
}
return 0;
} else {
@@ -587,8 +594,15 @@ static int spl_array_has_dimension_ex(int check_inherited, zval *object, zval *o
}
if (check_empty) {
HashTable *ht = spl_array_get_hash_table(intern, 0 TSRMLS_CC);
- if (zend_hash_index_find(ht, index, (void **)&tmp) != FAILURE && zend_is_true(*tmp)) {
- return 1;
+ 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;
} else {
diff --git a/ext/spl/tests/bug53515.phpt b/ext/spl/tests/bug53515.phpt
new file mode 100644
index 0000000000..f99840e322
--- /dev/null
+++ b/ext/spl/tests/bug53515.phpt
@@ -0,0 +1,27 @@
+--TEST--
+Bug #53515 (property_exists incorrect on ArrayObject null and 0 values)
+--FILE--
+<?php
+
+$a = array('a' => 1, 'b'=> true, 'c' => 0, 'd' => null, 'e' => false, 'f' => array());
+$o = new ArrayObject($a, ArrayObject::ARRAY_AS_PROPS);
+
+$a['z'] = '';
+$a[''] = '';
+
+foreach ($a as $key => $value) {
+ echo $key . ': ' . (is_null($value) ? 'null' : $value) .
+ ' array_key_exists: ' . (array_key_exists($key, $a) ? 'true' : 'false') .
+ ' property_exists: ' . (property_exists($o, $key) ? 'true' : 'false'),"\n";
+}
+
+?>
+--EXPECT--
+a: 1 array_key_exists: true property_exists: true
+b: 1 array_key_exists: true property_exists: true
+c: 0 array_key_exists: true property_exists: true
+d: null array_key_exists: true property_exists: true
+e: array_key_exists: true property_exists: true
+f: Array array_key_exists: true property_exists: true
+z: array_key_exists: true property_exists: false
+: array_key_exists: true property_exists: false