    	ZEND_NULL_HANDLER
    };
    zend_opcode_handlers = (opcode_handler_t*)labels;
-@@ -31041,6 +31450,145 @@
+@@ -29252,8 +29681,12 @@
+ 		EX(fbc) = ce->constructor;
+ 	}
+ 
+-	EX(calling_scope) = EX(fbc)->common.scope;
++#if DEBUG_ZEND>=2
++	fprintf(stderr, "Setting calling_scope for %s to %s (old: %s)\n", EX(fbc)->common.function_name, ce->name, EX(fbc)->common.scope->name);
++#endif
+ 
++	EX(calling_scope) = ce;
++    
+ 	if (EX(fbc)->common.fn_flags & ZEND_ACC_STATIC) {
+ 		EX(object) = NULL;
+ 	} else {
+@@ -31041,6 +31474,145 @@
  	ZEND_VM_NEXT_OPCODE();
  }
  

retrieving revision 1.107
diff -u -r1.107 zend_object_handlers.c
--- Zend/zend_object_handlers.c	17 Dec 2004 22:24:51 -0000	1.107
+++ Zend/zend_object_handlers.c	8 Jan 2005 22:42:51 -0000
@@ -480,7 +480,7 @@
 	zend_internal_function *func = (zend_internal_function *)EG(function_state_ptr)->function;
 	zval *method_name_ptr, *method_args_ptr;

retrieving revision 1.140
diff -u -r1.140 zend_globals.h
--- Zend/zend_globals.h	3 Nov 2004 23:13:32 -0000	1.140
+++ Zend/zend_globals.h	9 Jan 2005 00:30:29 -0000
@@ -73,8 +73,11 @@
 	zend_stack foreach_copy_stack;
 	zend_stack object_stack;
