cvs: ZendEngine2 / zend_compile.c zend_object_handlers.c
| From: | Zeev Suraski | Date: | Tue, 18 Mar 2003 16:30:24 +0000 |
| Subject: | cvs: ZendEngine2 / zend_compile.c zend_object_handlers.c | ||
| Groups: | php.zend-engine.cvs | ||
| Request: | Send a blank email to php-zend-engine-cvs+get-1048@lists.php.net to get a copy of this message | ||
zeev Tue Mar 18 11:30:24 2003 EDT
Modified files:
/ZendEngine2 zend_compile.c zend_object_handlers.c
Log:
- Fix situation where a derived class declares a public (or implicit public)
with the same name as a private in the parent
- Optimize 'static binding' of private properties a bit
Index: ZendEngine2/zend_compile.c
diff -u ZendEngine2/zend_compile.c:1.395 ZendEngine2/zend_compile.c:1.396
--- ZendEngine2/zend_compile.c:1.395 Wed Mar 12 04:38:19 2003
+++ ZendEngine2/zend_compile.c Tue Mar 18 11:30:23 2003
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_compile.c,v 1.395 2003/03/12 09:38:19 zeev Exp $ */
+/* $Id: zend_compile.c,v 1.396 2003/03/18 16:30:23 zeev Exp $ */
#include "zend_language_parser.h"
#include "zend.h"
@@ -1682,6 +1682,9 @@
zend_class_entry *parent_ce = ce->parent;
if (parent_info->flags & ZEND_ACC_PRIVATE) {
+ if (zend_hash_quick_find(&ce->properties_info, hash_key->arKey,
hash_key->nKeyLength, hash_key->h, (void **) &child_info)==SUCCESS) {
+ child_info->flags |= ZEND_ACC_CHANGED;
+ }
return 0; /* don't copy access information to child */
}
Index: ZendEngine2/zend_object_handlers.c
diff -u ZendEngine2/zend_object_handlers.c:1.43 ZendEngine2/zend_object_handlers.c:1.44
--- ZendEngine2/zend_object_handlers.c:1.43 Tue Mar 11 18:19:45 2003
+++ ZendEngine2/zend_object_handlers.c Tue Mar 18 11:30:23 2003
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_object_handlers.c,v 1.43 2003/03/11 23:19:45 zeev Exp $ */
+/* $Id: zend_object_handlers.c,v 1.44 2003/03/18 16:30:23 zeev Exp $ */
#include "zend.h"
#include "zend_globals.h"
@@ -179,24 +179,40 @@
static inline zend_property_info *zend_get_property_info(zend_object *zobj, zval *member TSRMLS_DC)
{
- zend_property_info *property_info;
- zend_bool found_info_in_object = 0;
+ 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)) {
- return property_info;
+ if (property_info->flags & ZEND_ACC_CHANGED
+ && !(property_info->flags & ZEND_ACC_PRIVATE)) {
+ /* We still need to make sure that we're not in a context
+ * where the right property is a different 'statically linked' private
+ * continue checking below...
+ */
+ } else {
+ return property_info;
+ }
} else {
- found_info_in_object = 1;
+ /* Try to look in the scope instead */
+ denied_access = 1;
}
}
- if (EG(scope)
- && zend_hash_quick_find(&EG(scope)->properties_info, Z_STRVAL_P(member),
Z_STRLEN_P(member)+1, h, (void **) &property_info)==SUCCESS
- && property_info->flags & ZEND_ACC_PRIVATE) {
- /* ok */
- } else if (found_info_in_object) {
- /* Information was available, but we were denied access. Error out. */
- zend_error(E_ERROR, "Cannot access %s property %s::$%s",
zend_visibility_string(property_info->flags), zobj->ce->name, Z_STRVAL_P(member));
+ if (EG(scope) != zobj->ce
+ && 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) {
+ return scope_property_info;
+ } else if (property_info) {
+ if (denied_access) {
+ /* Information was available, but we were denied access. Error out. */
+ zend_error(E_ERROR, "Cannot access %s property %s::$%s",
zend_visibility_string(property_info->flags), zobj->ce->name, Z_STRVAL_P(member));
+ } else {
+ /* fall through, return property_info... */
+ }
} else {
EG(std_property_info).flags = ZEND_ACC_PUBLIC;
EG(std_property_info).name = Z_STRVAL_P(member);