cvs: ZendEngine2 / zend_object_handlers.c /tests bug34893.phpt

From: Date: Thu, 20 Oct 2005 09:47:31 +0000
Subject: cvs: ZendEngine2 / zend_object_handlers.c /tests bug34893.phpt
Groups: php.zend-engine.cvs 
Request: Send a blank email to php-zend-engine-cvs+get-4267@lists.php.net to get a copy of this message
dmitry Thu Oct 20 05:47:31 2005 EDT Modified files: /ZendEngine2 zend_object_handlers.c /ZendEngine2/tests bug34893.phpt Log: Fixed bug #34893 (PHP5.1 overloading, Cannot access private property) http://cvs.php.net/diff.php/ZendEngine2/zend_object_handlers.c?r1=1.150&r2=1.151&ty=u Index: ZendEngine2/zend_object_handlers.c diff -u ZendEngine2/zend_object_handlers.c:1.150 ZendEngine2/zend_object_handlers.c:1.151 --- ZendEngine2/zend_object_handlers.c:1.150 Thu Oct 6 15:11:01 2005 +++ ZendEngine2/zend_object_handlers.c Thu Oct 20 05:47:31 2005 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_object_handlers.c,v 1.150 2005/10/06 19:11:01 helly Exp $ */ +/* $Id: zend_object_handlers.c,v 1.151 2005/10/20 09:47:31 dmitry Exp $ */ #include "zend.h" #include "zend_globals.h" @@ -490,8 +490,10 @@ zval tmp_member; zval **retval; zend_property_info *property_info; + zend_bool use_get; zobj = Z_OBJ_P(object); + use_get = (zobj->ce->__get && !zobj->in_get); if (member->type != IS_UNICODE && (UG(unicode) || member->type != IS_STRING)) { tmp_member = *member; @@ -504,12 +506,12 @@ fprintf(stderr, "Ptr object #%d property: %R\n", Z_OBJ_HANDLE_P(object), Z_TYPE_P(member), Z_STRVAL_P(member)); #endif - property_info = zend_get_property_info(zobj->ce, member, 0 TSRMLS_CC); + property_info = zend_get_property_info(zobj->ce, member, use_get TSRMLS_CC); - if (zend_u_hash_quick_find(zobj->properties, Z_TYPE_P(member), property_info->name, property_info->name_length+1, property_info->h, (void **) &retval) == FAILURE) { + if (!property_info || zend_u_hash_quick_find(zobj->properties, Z_TYPE_P(member), property_info->name, property_info->name_length+1, property_info->h, (void **) &retval) == FAILURE) { zval *new_zval; - if (!zobj->ce->__get && !zobj->ce->__set) { + if (!use_get) { /* we don't have access controls - will just add it */ new_zval = &EG(uninitialized_zval); http://cvs.php.net/diff.php/ZendEngine2/tests/bug34893.phpt?r1=1.1&r2=1.2&ty=u Index: ZendEngine2/tests/bug34893.phpt diff -u /dev/null ZendEngine2/tests/bug34893.phpt:1.2 --- /dev/null Thu Oct 20 05:47:31 2005 +++ ZendEngine2/tests/bug34893.phpt Thu Oct 20 05:47:31 2005 @@ -0,0 +1,33 @@ +--TEST-- +Bug #34893 (PHP5.1 overloading, Cannot access private property) +--FILE-- +<?php +class A { + private $p; + function __get($name){ + return $this->$name; + } + function __set($name, $value) { + $this->$name = $value; + } +} +class B { + private $t; + function __get($name){ + return $this->$name; + } + function __set($name, $value) { + $this->$name = $value; + } +} +$a = new A; +$b = new B; +$a->p = $b; +$b->t = "foo"; + +echo $a->p->t; +$a->p->t = "bar"; +echo $a->p->t; +?> +--EXPECT-- +foobar

« previous php.zend-engine.cvs (#4267) next »