felipe                                   Fri, 10 Dec 2010 23:58:33 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=306213

Log:
- Fixed bug #53515 (property_exists incorrect on ArrayObject null and 0 values)

Bug: http://bugs.php.net/53515 (Open) property_exists incorrect on ArrayObject 
null and 0 values
      
Changed paths:
    U   php/php-src/branches/PHP_5_3/NEWS
    U   php/php-src/branches/PHP_5_3/ext/spl/spl_array.c
    A   php/php-src/branches/PHP_5_3/ext/spl/tests/bug53515.phpt
    U   php/php-src/trunk/ext/spl/spl_array.c
    A   php/php-src/trunk/ext/spl/tests/bug53515.phpt

Modified: php/php-src/branches/PHP_5_3/NEWS
===================================================================
--- php/php-src/branches/PHP_5_3/NEWS   2010-12-10 22:51:08 UTC (rev 306212)
+++ php/php-src/branches/PHP_5_3/NEWS   2010-12-10 23:58:33 UTC (rev 306213)
@@ -1,6 +1,10 @@
 PHP                                                                        
NEWS
 |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
 ?? ??? 20??, PHP 5.3.5
+- Zend Engine:
+  . Indirect reference to $this fails to resolve if direct $this is never used
+    in method. (Scott)
+
 - Intl extension:
   . Fixed bug #53512 (NumberFormatter::setSymbol crash on bogus $attr values).
     (Felipe)
@@ -13,9 +17,9 @@
   . Fixed bug #53517 (segfault in pgsql_stmt_execute() when postgres is down).
     (gyp at balabit dot hu)

-- Zend Engine:
-  . Indirect reference to $this fails to resolve if direct $this is never used
-    in method. (Scott)
+- SPL extension:
+  . Fixed bug #53515 (property_exists incorrect on ArrayObject null and 0
+    values). (Felipe)

 09 Dec 2010, PHP 5.3.4
 - Upgraded bundled Sqlite3 to version 3.7.3. (Ilia)

Modified: php/php-src/branches/PHP_5_3/ext/spl/spl_array.c
===================================================================
--- php/php-src/branches/PHP_5_3/ext/spl/spl_array.c    2010-12-10 22:51:08 UTC 
(rev 306212)
+++ php/php-src/branches/PHP_5_3/ext/spl/spl_array.c    2010-12-10 23:58:33 UTC 
(rev 306213)
@@ -579,8 +579,15 @@
        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 {
@@ -597,8 +604,15 @@
                }
                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 {

Added: php/php-src/branches/PHP_5_3/ext/spl/tests/bug53515.phpt
===================================================================
--- php/php-src/branches/PHP_5_3/ext/spl/tests/bug53515.phpt                    
        (rev 0)
+++ php/php-src/branches/PHP_5_3/ext/spl/tests/bug53515.phpt    2010-12-10 
23:58:33 UTC (rev 306213)
@@ -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


Property changes on: php/php-src/branches/PHP_5_3/ext/spl/tests/bug53515.phpt
___________________________________________________________________
Added: svn:keywords
   + Id Rev Revision
Added: svn:eol-style
   + native

Modified: php/php-src/trunk/ext/spl/spl_array.c
===================================================================
--- php/php-src/trunk/ext/spl/spl_array.c       2010-12-10 22:51:08 UTC (rev 
306212)
+++ php/php-src/trunk/ext/spl/spl_array.c       2010-12-10 23:58:33 UTC (rev 
306213)
@@ -569,8 +569,15 @@
        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 @@
                }
                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 {

Added: php/php-src/trunk/ext/spl/tests/bug53515.phpt
===================================================================
--- php/php-src/trunk/ext/spl/tests/bug53515.phpt                               
(rev 0)
+++ php/php-src/trunk/ext/spl/tests/bug53515.phpt       2010-12-10 23:58:33 UTC 
(rev 306213)
@@ -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


Property changes on: php/php-src/trunk/ext/spl/tests/bug53515.phpt
___________________________________________________________________
Added: svn:keywords
   + Id Rev Revision
Added: svn:eol-style
   + native

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to