zeev Mon Jul 21 08:13:16 2003 EDT
Added files:
/php-src/tests/lang bug24499.phpt
Modified files:
/ZendEngine2 zend_object_handlers.c
Log:
Fix bug #24499
Index: ZendEngine2/zend_object_handlers.c
diff -u ZendEngine2/zend_object_handlers.c:1.59 ZendEngine2/zend_object_handlers.c:1.60
--- ZendEngine2/zend_object_handlers.c:1.59 Mon Jul 7 06:53:27 2003
+++ ZendEngine2/zend_object_handlers.c Mon Jul 21 08:13:16 2003
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_object_handlers.c,v 1.59 2003/07/07 10:53:27 zeev Exp $ */
+/* $Id: zend_object_handlers.c,v 1.60 2003/07/21 12:13:16 zeev Exp $ */
#include "zend.h"
#include "zend_globals.h"
@@ -178,13 +178,25 @@
return 0;
}
+static inline zend_bool is_derived_class(zend_class_entry *child_class,
zend_class_entry *parent_class)
+{
+ child_class = child_class->parent;
+ while (child_class) {
+ if (child_class == parent_class) {
+ return 1;
+ }
+ child_class = child_class->parent;
+ }
+
+ return 0;
+}
+
static inline zend_property_info *zend_get_property_info(zend_object *zobj, zval
*member TSRMLS_DC)
{
zend_property_info *property_info = NULL;
zend_property_info *scope_property_info;
zend_bool denied_access = 0;
-
ulong h = zend_get_hash_value(Z_STRVAL_P(member), Z_STRLEN_P(member)+1);
if (zend_hash_quick_find(&zobj->ce->properties_info, Z_STRVAL_P(member),
Z_STRLEN_P(member)+1, h, (void **) &property_info)==SUCCESS) {
if (zend_verify_property_access(property_info, zobj->ce TSRMLS_CC)) {
@@ -203,6 +215,7 @@
}
}
if (EG(scope) != zobj->ce
+ && is_derived_class(zobj->ce, EG(scope))
&& EG(scope)
&& zend_hash_quick_find(&EG(scope)->properties_info,
Z_STRVAL_P(member), Z_STRLEN_P(member)+1, h, (void **) &scope_property_info)==SUCCESS
&& scope_property_info->flags & ZEND_ACC_PRIVATE) {
Index: php-src/tests/lang/bug24499.phpt
+++ php-src/tests/lang/bug24499.phpt
--TEST--
Bug #24499 (bogus handling of a public property as a private one)
--FILE--
<?php
class Id {
private $id="priv";
public function tester($obj)
{
$obj->id = "bar";
}
}
$id = new Id();
@$obj->foo = "bar";
$id->tester($obj);
print_r($obj);
?>
--EXPECT--
stdClass Object
(
[foo] => bar
[id] => bar
)
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php