cvs: ZendEngine2 / zend_object_handlers.c /tests bug33171.phpt
| From: | Dmitry Stogov | Date: | Mon, 06 Jun 2005 07:52:09 +0000 |
| Subject: | cvs: ZendEngine2 / zend_object_handlers.c /tests bug33171.phpt | ||
| Groups: | php.zend-engine.cvs | ||
| Request: | Send a blank email to php-zend-engine-cvs+get-3713@lists.php.net to get a copy of this message | ||
dmitry Mon Jun 6 03:52:09 2005 EDT
Modified files:
/ZendEngine2 zend_object_handlers.c
/ZendEngine2/tests bug33171.phpt
Log:
Fixed bug #33171 (foreach enumerates private fields declared in base classes)
http://cvs.php.net/diff.php/ZendEngine2/zend_object_handlers.c?r1=1.127&r2=1.128&ty=u
Index: ZendEngine2/zend_object_handlers.c
diff -u ZendEngine2/zend_object_handlers.c:1.127 ZendEngine2/zend_object_handlers.c:1.128
--- ZendEngine2/zend_object_handlers.c:1.127 Fri Jun 3 07:16:17 2005
+++ ZendEngine2/zend_object_handlers.c Mon Jun 6 03:52:08 2005
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_object_handlers.c,v 1.127 2005/06/03 11:16:17 dmitry Exp $ */
+/* $Id: zend_object_handlers.c,v 1.128 2005/06/06 07:52:08 dmitry Exp $ */
#include "zend.h"
#include "zend_globals.h"
@@ -214,9 +214,14 @@
if (!property_info) {
return FAILURE;
}
- if (prop_info_name[0] == '\0' && prop_info_name[1] != '*' &&
!(property_info->flags & ZEND_ACC_PRIVATE)) {
- /* we we're looking for a private prop but found a non private one of the same name */
- return FAILURE;
+ if (prop_info_name[0] == '\0' && prop_info_name[1] != '*') {
+ if (!(property_info->flags & ZEND_ACC_PRIVATE)) {
+ /* we we're looking for a private prop but found a non private one of the same name */
+ return FAILURE;
+ } else if (strcmp(prop_info_name+1, property_info->name+1)) {
+ /* we we're looking for a private prop but found a private one of the same name but another
class */
+ return FAILURE;
+ }
}
return zend_verify_property_access(property_info, zobj->ce TSRMLS_CC) ? SUCCESS : FAILURE;
}
http://cvs.php.net/diff.php/ZendEngine2/tests/bug33171.phpt?r1=1.1&r2=1.2&ty=u
Index: ZendEngine2/tests/bug33171.phpt
diff -u /dev/null ZendEngine2/tests/bug33171.phpt:1.2
--- /dev/null Mon Jun 6 03:52:09 2005
+++ ZendEngine2/tests/bug33171.phpt Mon Jun 6 03:52:08 2005
@@ -0,0 +1,27 @@
+--TEST--
+Bug #33171 (foreach enumerates private fields declared in base classes)
+--FILE--
+<?php
+class A
+{
+ private $c = "A's c";
+}
+
+class B extends A
+{
+ private $c = "B's c";
+
+ public function go()
+ {
+ foreach ($this as $key => $val)
+ {
+ echo "$key => $val\n";
+ }
+ }
+};
+
+$x = new B;
+$x->go();
+?>
+--EXPECT--
+c => B's c