cvs: ZendEngine2(PHP_5_2) / zend_API.c zend_compile.h zend_object_handlers.c /tests bug37212.phpt
| From: | Marcus Boerger | Date: | Sat, 27 May 2006 18:39:54 +0000 |
| Subject: | cvs: ZendEngine2(PHP_5_2) / 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-4934@lists.php.net to get a copy of this message | ||
helly Sat May 27 18:39:54 2006 UTC
Added files: (Branch: PHP_5_2)
/ZendEngine2/tests bug37212.phpt
Modified files:
/ZendEngine2 zend_API.c zend_compile.h zend_object_handlers.c
Log:
- MFH: Fix bug #37212 (Access to protected property of common base class)
By adding "zend_class_entry *ce" to struct zend_property_info;
http://cvs.php.net/viewcvs.cgi/ZendEngine2/zend_API.c?r1=1.296.2.27.2.10&r2=1.296.2.27.2.11&diff_format=u
Index: ZendEngine2/zend_API.c
diff -u ZendEngine2/zend_API.c:1.296.2.27.2.10 ZendEngine2/zend_API.c:1.296.2.27.2.11
--- ZendEngine2/zend_API.c:1.296.2.27.2.10 Thu May 25 10:01:06 2006
+++ ZendEngine2/zend_API.c Sat May 27 18:39:53 2006
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_API.c,v 1.296.2.27.2.10 2006/05/25 10:01:06 tony2001 Exp $ */
+/* $Id: zend_API.c,v 1.296.2.27.2.11 2006/05/27 18:39:53 helly Exp $ */
#include "zend.h"
#include "zend_execute.h"
@@ -2376,6 +2376,8 @@
property_info.doc_comment = doc_comment;
property_info.doc_comment_len = doc_comment_len;
+
+ property_info.ce = ce;
zend_hash_update(&ce->properties_info, name, name_length + 1, &property_info,
sizeof(zend_property_info), NULL);
http://cvs.php.net/viewcvs.cgi/ZendEngine2/zend_compile.h?r1=1.316.2.8.2.2&r2=1.316.2.8.2.3&diff_format=u
Index: ZendEngine2/zend_compile.h
diff -u ZendEngine2/zend_compile.h:1.316.2.8.2.2 ZendEngine2/zend_compile.h:1.316.2.8.2.3
--- ZendEngine2/zend_compile.h:1.316.2.8.2.2 Thu May 11 21:07:39 2006
+++ ZendEngine2/zend_compile.h Sat May 27 18:39:53 2006
@@ -5,7 +5,7 @@
| Copyright (c) 1998-2006 Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 2.00 of the Zend license, |
- | that is bundled with this package in the file LICENSE, and is |
+ | that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.zend.com/license/2_00.txt.
|
| If you did not receive a copy of the Zend license and are unable to |
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_compile.h,v 1.316.2.8.2.2 2006/05/11 21:07:39 helly Exp $ */
+/* $Id: zend_compile.h,v 1.316.2.8.2.3 2006/05/27 18:39:53 helly Exp $ */
#ifndef ZEND_COMPILE_H
#define ZEND_COMPILE_H
@@ -149,6 +149,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_object_handlers.c?r1=1.135.2.6.2.2&r2=1.135.2.6.2.3&diff_format=u
Index: ZendEngine2/zend_object_handlers.c
diff -u ZendEngine2/zend_object_handlers.c:1.135.2.6.2.2
ZendEngine2/zend_object_handlers.c:1.135.2.6.2.3
--- ZendEngine2/zend_object_handlers.c:1.135.2.6.2.2 Wed May 10 21:12:48 2006
+++ ZendEngine2/zend_object_handlers.c Sat May 27 18:39:53 2006
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_object_handlers.c,v 1.135.2.6.2.2 2006/05/10 21:12:48 helly Exp $ */
+/* $Id: zend_object_handlers.c,v 1.135.2.6.2.3 2006/05/27 18:39:53 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;
@@ -190,7 +190,7 @@
zend_error(E_ERROR, "Cannot access property started with '\\0'");
}
}
- return NULL;
+ return NULL;
}
h = zend_get_hash_value(Z_STRVAL_P(member), Z_STRLEN_P(member) + 1);
if (zend_hash_quick_find(&ce->properties_info, Z_STRVAL_P(member), Z_STRLEN_P(member)+1, h,
(void **) &property_info)==SUCCESS) {
@@ -238,6 +238,7 @@
EG(std_property_info).name = Z_STRVAL_P(member);
EG(std_property_info).name_length = Z_STRLEN_P(member);
EG(std_property_info).h = h;
+ EG(std_property_info).ce = ce;
property_info = &EG(std_property_info);
}
return property_info;
@@ -579,7 +580,7 @@
zend_get_property_guard(zobj, property_info, member, &guard) == SUCCESS &&
!guard->in_unset) {
/* have unseter - try with it! */
- guard->in_unset = 1; /* prevent circular setting */
+ guard->in_unset = 1; /* prevent circular unsetting */
zend_std_call_unsetter(object, member TSRMLS_CC);
guard->in_unset = 0;
}
@@ -842,6 +843,7 @@
std_property_info.name = property_name;
std_property_info.name_length = property_name_len;
std_property_info.h = zend_get_hash_value(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/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===