dmitry          Tue Jul 24 11:40:08 2007 UTC

  Modified files:              
    /ZendEngine2        zend_builtin_functions.c zend_object_handlers.c 
    /ZendEngine2/tests  bug40757.phpt bug41929.phpt bug27798.phpt 
    /php-src/tests/classes      visibility_005.phpt 
  Log:
  Fixed bug #40757 (get_object_vars get nothing in child class)
  Fixed bug #41929 (Foreach on object does not iterate over all visible 
properties)
  
  
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_builtin_functions.c?r1=1.342&r2=1.343&diff_format=u
Index: ZendEngine2/zend_builtin_functions.c
diff -u ZendEngine2/zend_builtin_functions.c:1.342 
ZendEngine2/zend_builtin_functions.c:1.343
--- ZendEngine2/zend_builtin_functions.c:1.342  Tue Jul 10 15:06:58 2007
+++ ZendEngine2/zend_builtin_functions.c        Tue Jul 24 11:40:07 2007
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_builtin_functions.c,v 1.342 2007/07/10 15:06:58 tony2001 Exp $ */
+/* $Id: zend_builtin_functions.c,v 1.343 2007/07/24 11:40:07 dmitry Exp $ */
 
 #include "zend.h"
 #include "zend_API.h"
@@ -816,7 +816,7 @@
        zstr key, prop_name, class_name;
        uint key_len;
        ulong num_index;
-       int instanceof;
+       zend_object *zobj;
 
        if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &obj) == FAILURE) 
{
                ZEND_WRONG_PARAM_COUNT();
@@ -835,7 +835,7 @@
                RETURN_FALSE;
        }
 
-       instanceof = EG(This) && instanceof_function(Z_OBJCE_P(EG(This)), 
Z_OBJCE_PP(obj) TSRMLS_CC);
+       zobj = zend_objects_get_address(*obj TSRMLS_CC);
 
        array_init(return_value);
 
@@ -843,19 +843,11 @@
 
        while (zend_hash_get_current_data_ex(properties, (void **) &value, 
&pos) == SUCCESS) {
                if (zend_hash_get_current_key_ex(properties, &key, &key_len, 
&num_index, 0, &pos) == (UG(unicode)?HASH_KEY_IS_UNICODE:HASH_KEY_IS_STRING)) {
-                       
zend_u_unmangle_property_name(UG(unicode)?IS_UNICODE:IS_STRING, key, key_len-1, 
&class_name, &prop_name);
-                       if (class_name.v == NULL) {
+                       if (zend_check_property_access(zobj, ZEND_STR_TYPE, 
key, key_len-1 TSRMLS_CC) == SUCCESS) {
+                               zend_u_unmangle_property_name(ZEND_STR_TYPE, 
key, key_len-1, &class_name, &prop_name);
                                /* Not separating references */
                                (*value)->refcount++;
-                               add_u_assoc_zval_ex(return_value, 
UG(unicode)?IS_UNICODE:IS_STRING, key, key_len, *value);
-                       } else if (instanceof) {
-                               if (class_name.s[0] == '*' ||
-                                   (Z_OBJCE_P(EG(This)) == Z_OBJCE_PP(obj) &&
-                                   
UG(unicode)?!u_strcmp(Z_OBJCE_P(EG(This))->name.u, 
class_name.u):!strcmp(Z_OBJCE_P(EG(This))->name.s, class_name.s))) {
-                                       /* Not separating references */
-                                       (*value)->refcount++;
-                                       add_u_assoc_zval(return_value, 
UG(unicode)?IS_UNICODE:IS_STRING, prop_name, *value);
-                               }
+                               add_u_assoc_zval(return_value, ZEND_STR_TYPE, 
prop_name, *value);
                        }
                }
                zend_hash_move_forward_ex(properties, &pos);
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_object_handlers.c?r1=1.187&r2=1.188&diff_format=u
Index: ZendEngine2/zend_object_handlers.c
diff -u ZendEngine2/zend_object_handlers.c:1.187 
ZendEngine2/zend_object_handlers.c:1.188
--- ZendEngine2/zend_object_handlers.c:1.187    Sat Jul 21 05:27:07 2007
+++ ZendEngine2/zend_object_handlers.c  Tue Jul 24 11:40:07 2007
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_object_handlers.c,v 1.187 2007/07/21 05:27:07 pollita Exp $ */
+/* $Id: zend_object_handlers.c,v 1.188 2007/07/24 11:40:07 dmitry Exp $ */
 
 #include "zend.h"
 #include "zend_globals.h"
@@ -164,7 +164,7 @@
                case ZEND_ACC_PROTECTED:
                        return zend_check_protected(property_info->ce, 
EG(scope));
                case ZEND_ACC_PRIVATE:
-                       if (ce==EG(scope) && EG(scope)) {
+                       if ((ce==EG(scope) || property_info->ce == EG(scope)) 
&& EG(scope)) {
                                return 1;
                        } else {
                                return 0;
http://cvs.php.net/viewvc.cgi/ZendEngine2/tests/bug40757.phpt?r1=1.1&r2=1.2&diff_format=u
Index: ZendEngine2/tests/bug40757.phpt
diff -u /dev/null ZendEngine2/tests/bug40757.phpt:1.2
--- /dev/null   Tue Jul 24 11:40:07 2007
+++ ZendEngine2/tests/bug40757.phpt     Tue Jul 24 11:40:07 2007
@@ -0,0 +1,28 @@
+--TEST--
+Bug #40757 (get_object_vars() get nothing in child class)
+--FILE--
+<?php
+class Base {
+  private $p1='sadf';
+
+  function getFields($obj){
+    return get_object_vars($obj);
+  }
+}
+
+class Child extends Base { }
+
+$base=new Base();
+print_r($base->getFields(new Base()));
+$child=new Child();
+print_r($child->getFields(new Base()));
+?>
+--EXPECT--
+Array
+(
+    [p1] => sadf
+)
+Array
+(
+    [p1] => sadf
+)
http://cvs.php.net/viewvc.cgi/ZendEngine2/tests/bug41929.phpt?r1=1.1&r2=1.2&diff_format=u
Index: ZendEngine2/tests/bug41929.phpt
diff -u /dev/null ZendEngine2/tests/bug41929.phpt:1.2
--- /dev/null   Tue Jul 24 11:40:07 2007
+++ ZendEngine2/tests/bug41929.phpt     Tue Jul 24 11:40:07 2007
@@ -0,0 +1,24 @@
+--TEST--
+Bug #41929 Foreach on object does not iterate over all visible properties 
+--FILE--
+<?php
+class C {
+  private $priv = "ok";
+
+  function doLoop() {
+    echo $this->priv,"\n";
+    foreach ($this as $k=>$v) {
+      echo "$k: $v\n";
+    }
+  } 
+}
+
+class D extends C {
+}
+
+$myD = new D;
+$myD->doLoop();
+?>
+--EXPECT--
+ok
+priv: ok
http://cvs.php.net/viewvc.cgi/ZendEngine2/tests/bug27798.phpt?r1=1.2&r2=1.3&diff_format=u
Index: ZendEngine2/tests/bug27798.phpt
diff -u ZendEngine2/tests/bug27798.phpt:1.2 ZendEngine2/tests/bug27798.phpt:1.3
--- ZendEngine2/tests/bug27798.phpt:1.2 Mon Aug 15 14:37:54 2005
+++ ZendEngine2/tests/bug27798.phpt     Tue Jul 24 11:40:07 2007
@@ -49,12 +49,12 @@
 }
 Base::__construct
 array(3) {
-  ["Baz"]=>
-  int(4)
   ["Foo"]=>
   int(1)
   ["Bar"]=>
   int(2)
+  ["Baz"]=>
+  int(3)
 }
 Child::__construct
 array(3) {
@@ -86,12 +86,12 @@
 }
 Base::__construct
 array(3) {
-  [u"Baz"]=>
-  int(4)
   [u"Foo"]=>
   int(1)
   [u"Bar"]=>
   int(2)
+  [u"Baz"]=>
+  int(3)
 }
 Child::__construct
 array(3) {
http://cvs.php.net/viewvc.cgi/php-src/tests/classes/visibility_005.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/tests/classes/visibility_005.phpt
diff -u php-src/tests/classes/visibility_005.phpt:1.1 
php-src/tests/classes/visibility_005.phpt:1.2
--- php-src/tests/classes/visibility_005.phpt:1.1       Fri Dec 19 10:16:08 2003
+++ php-src/tests/classes/visibility_005.phpt   Tue Jul 24 11:40:07 2007
@@ -52,6 +52,7 @@
 ===derived::function===
 a=>1
 b=>2
+c=>3
 d=>4
 ===derived,foreach===
 a=>1

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

Reply via email to