cvs: ZendEngine2 / zend_API.c zend_compile.h zend_object_handlers.c /tests bug37212.phpt

From: Date: Sat, 27 May 2006 02:12:43 +0000
Subject: cvs: ZendEngine2 / zend_API.c zend_compile.h zend_object_handlers.c /tests bug37212.phpt
Groups: php.zend-engine.cvs 
Request: Send a blank email to php-zend-engine-cvs+get-4930@lists.php.net to get a copy of this message
helly Sat May 27 02:12:43 2006 UTC Added files: /ZendEngine2/tests bug37212.phpt Modified files: /ZendEngine2 zend_object_handlers.c zend_compile.h zend_API.c Log: - Fix bug #37212 (Access to protected property of common base class) By adding "zend_class_entry *ce" to struct zend_property_info; # Besides closing the bug this patch allows to optimize a bunch of # property handling optimizations. I need to find out what all can be # optimized. All other tests relevant to class handling still PASS. http://cvs.php.net/viewcvs.cgi/ZendEngine2/zend_object_handlers.c?r1=1.164&r2=1.165&diff_format=u Index: ZendEngine2/zend_object_handlers.c diff -u ZendEngine2/zend_object_handlers.c:1.164 ZendEngine2/zend_object_handlers.c:1.165 --- ZendEngine2/zend_object_handlers.c:1.164 Thu May 18 21:14:40 2006 +++ ZendEngine2/zend_object_handlers.c Sat May 27 02:12:43 2006 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_object_handlers.c,v 1.164 2006/05/18 21:14:40 helly Exp $ */ +/* $Id: zend_object_handlers.c,v 1.165 2006/05/27 02:12:43 helly Exp $ */ #include "zend.h" #include "zend_globals.h" @@ -150,7 +150,7 @@ case ZEND_ACC_PUBLIC: return 1; case ZEND_ACC_PROTECTED: - return zend_check_protected(ce, EG(scope)); + return zend_check_protected(property_info->ce, EG(scope)); case ZEND_ACC_PRIVATE: if (ce==EG(scope) && EG(scope)) { return 1; @@ -239,6 +239,7 @@ EG(std_property_info).name = Z_UNIVAL_P(member); EG(std_property_info).name_length = Z_UNILEN_P(member); EG(std_property_info).h = h; + EG(std_property_info).ce = ce;; property_info = &EG(std_property_info); } return property_info; @@ -866,6 +867,7 @@ std_property_info.name = property_name; std_property_info.name_length = property_name_len; std_property_info.h = zend_u_get_hash_value(UG(unicode)?IS_UNICODE:IS_STRING, std_property_info.name, std_property_info.name_length+1); + std_property_info.ce = ce; property_info = &std_property_info; } http://cvs.php.net/viewcvs.cgi/ZendEngine2/zend_compile.h?r1=1.341&r2=1.342&diff_format=u Index: ZendEngine2/zend_compile.h diff -u ZendEngine2/zend_compile.h:1.341 ZendEngine2/zend_compile.h:1.342 --- ZendEngine2/zend_compile.h:1.341 Thu May 11 18:22:09 2006 +++ ZendEngine2/zend_compile.h Sat May 27 02:12:43 2006 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_compile.h,v 1.341 2006/05/11 18:22:09 andrei Exp $ */ +/* $Id: zend_compile.h,v 1.342 2006/05/27 02:12:43 helly Exp $ */ #ifndef ZEND_COMPILE_H #define ZEND_COMPILE_H @@ -153,6 +153,7 @@ ulong h; char *doc_comment; int doc_comment_len; + zend_class_entry *ce; } zend_property_info; http://cvs.php.net/viewcvs.cgi/ZendEngine2/zend_API.c?r1=1.365&r2=1.366&diff_format=u Index: ZendEngine2/zend_API.c diff -u ZendEngine2/zend_API.c:1.365 ZendEngine2/zend_API.c:1.366 --- ZendEngine2/zend_API.c:1.365 Fri May 26 04:22:46 2006 +++ ZendEngine2/zend_API.c Sat May 27 02:12:43 2006 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_API.c,v 1.365 2006/05/26 04:22:46 pollita Exp $ */ +/* $Id: zend_API.c,v 1.366 2006/05/27 02:12:43 helly Exp $ */ #include "zend.h" #include "zend_execute.h" @@ -3028,6 +3028,8 @@ property_info.doc_comment = doc_comment; property_info.doc_comment_len = doc_comment_len; + + property_info.ce = ce; zend_u_hash_update(&ce->properties_info, type, name, name_length + 1, &property_info, sizeof(zend_property_info), NULL); http://cvs.php.net/viewcvs.cgi/ZendEngine2/tests/bug37212.phpt?view=markup&rev=1.1 Index: ZendEngine2/tests/bug37212.phpt +++ ZendEngine2/tests/bug37212.phpt --TEST-- Bug #3721 (Access to protected property of common base class) --FILE-- <?php class A { protected $value; public function __construct($val) { $this->value = $val; } protected function getValue() { return $this->value; } } class B extends A { public function copyValue($obj) { $this->value = $obj->getValue(); $this->value = $obj->value; // value defined in common base class } } class C extends A {} $B = new B("B"); var_dump($B); $C = new C("C"); var_dump($C); $B->copyValue($C); var_dump($B); ?> ===DONE=== --EXPECTF-- object(B)#%d (1) { ["value":protected]=> string(1) "B" } object(C)#%d (1) { ["value":protected]=> string(1) "C" } object(B)#%d (1) { ["value":protected]=> string(1) "C" } ===DONE=== --UEXPECTF-- object(B)#%d (1) { [u"value":protected]=> unicode(1) "B" } object(C)#%d (1) { [u"value":protected]=> unicode(1) "C" } object(B)#%d (1) { [u"value":protected]=> unicode(1) "C" } ===DONE===

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