diff options
author | Dmitry Stogov <dmitry@php.net> | 2005-10-20 09:47:12 +0000 |
---|---|---|
committer | Dmitry Stogov <dmitry@php.net> | 2005-10-20 09:47:12 +0000 |
commit | a8c338aa65c1fc48b53e67c95a9dd33b07d60486 (patch) | |
tree | 20ea689b17f703ecc2c545aebd9609be3f849e4c | |
parent | c326593c1a1e82c2fec2072b38176552d20c0169 (diff) | |
download | php-git-a8c338aa65c1fc48b53e67c95a9dd33b07d60486.tar.gz |
Fixed bug #34893 (PHP5.1 overloading, Cannot access private property)
-rw-r--r-- | NEWS | 2 | ||||
-rwxr-xr-x | Zend/tests/bug34893.phpt | 33 | ||||
-rw-r--r-- | Zend/zend_object_handlers.c | 8 |
3 files changed, 40 insertions, 3 deletions
@@ -3,6 +3,8 @@ PHP NEWS ?? Oct 2005, PHP 5.1 Release Candidate 4 - Fixed bug #34905 (Digest authentication does not work with Apache 1). (Ilia) - Fixed bug #34902 (mysqli::character_set_name() - undefined method). (Tony) +- Fixed bug #34893 (PHP5.1 overloading, Cannot access private property). + (Dmitry) - Fixed bug #34899 (Fixed sqlite extension compile failure). (Ilia) - Fixed bug #34767 (Zend Engine 1 Compatibility not copying objects correctly). (Dmitry) diff --git a/Zend/tests/bug34893.phpt b/Zend/tests/bug34893.phpt new file mode 100755 index 0000000000..bbe02358e9 --- /dev/null +++ b/Zend/tests/bug34893.phpt @@ -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 diff --git a/Zend/zend_object_handlers.c b/Zend/zend_object_handlers.c index 89cf73686a..49b5e1d6cf 100644 --- a/Zend/zend_object_handlers.c +++ b/Zend/zend_object_handlers.c @@ -482,8 +482,10 @@ static zval **zend_std_get_property_ptr_ptr(zval *object, zval *member TSRMLS_DC 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_STRING) { tmp_member = *member; @@ -496,12 +498,12 @@ static zval **zend_std_get_property_ptr_ptr(zval *object, zval *member TSRMLS_DC fprintf(stderr, "Ptr object #%d property: %s\n", Z_OBJ_HANDLE_P(object), 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_hash_quick_find(zobj->properties, property_info->name, property_info->name_length+1, property_info->h, (void **) &retval) == FAILURE) { + if (!property_info || zend_hash_quick_find(zobj->properties, 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); |