cvs: ZendEngine2 / zend_compile.c zend_execute.c
| From: | Andi Gutmans | Date: | Sun, 23 Jun 2002 15:46:58 +0000 |
| Subject: | cvs: ZendEngine2 / zend_compile.c zend_execute.c | ||
| Groups: | php.zend-engine.cvs | ||
| Request: | Send a blank email to php-zend-engine-cvs+get-190@lists.php.net to get a copy of this message | ||
andi Sun Jun 23 11:46:58 2002 EDT
Modified files:
/ZendEngine2 zend_compile.c zend_execute.c
Log:
- Fix problem with constructor not being inherited and called correctly.
Index: ZendEngine2/zend_compile.c
diff -u ZendEngine2/zend_compile.c:1.286 ZendEngine2/zend_compile.c:1.287
--- ZendEngine2/zend_compile.c:1.286 Wed Jun 5 13:34:56 2002
+++ ZendEngine2/zend_compile.c Sun Jun 23 11:46:58 2002
@@ -1476,16 +1476,25 @@
static void do_inherit_parent_constructor(zend_class_entry *ce)
{
- if (ce->parent
- && !zend_hash_exists(&ce->function_table, ce->name, ce->name_length+1)) {
- zend_function *function;
+ zend_function *function;
+ if (!ce->parent || ce->constructor) {
+ return;
+ }
+
+ if (!zend_hash_exists(&ce->function_table, ce->name, ce->name_length+1)) {
if (zend_hash_find(&ce->parent->function_table, ce->parent->name,
ce->parent->name_length+1, (void **) &function)==SUCCESS) {
/* inherit parent's constructor */
zend_hash_update(&ce->function_table, ce->name, ce->name_length+1, function,
sizeof(zend_function), NULL);
function_add_ref(function);
}
}
+ if (zend_hash_find(&ce->parent->function_table, ZEND_CONSTRUCTOR_FUNC_NAME,
sizeof(ZEND_CONSTRUCTOR_FUNC_NAME), (void **) &function)==SUCCESS) {
+ /* inherit parent's constructor */
+ zend_hash_update(&ce->function_table, ZEND_CONSTRUCTOR_FUNC_NAME,
sizeof(ZEND_CONSTRUCTOR_FUNC_NAME), function, sizeof(zend_function), NULL);
+ function_add_ref(function);
+ }
+ ce->constructor = ce->parent->constructor;
}
void zend_do_inheritance(zend_class_entry *ce, zend_class_entry *parent_ce)
Index: ZendEngine2/zend_execute.c
diff -u ZendEngine2/zend_execute.c:1.346 ZendEngine2/zend_execute.c:1.347
--- ZendEngine2/zend_execute.c:1.346 Sun Jun 16 14:25:05 2002
+++ ZendEngine2/zend_execute.c Sun Jun 23 11:46:58 2002
@@ -1892,7 +1892,9 @@
EX(fbc) = EX(fbc_constructor);
if(EX(fbc)->type == ZEND_USER_FUNCTION) { /* HACK!! */
- EX(calling_scope) = Z_OBJCE_P(EX(object));
+ /* The scope should be the scope of the class where the constructor
+ was initially declared in */
+ EX(calling_scope) = EX(fbc)->common.scope;
} else {
EX(calling_scope) = NULL;
}