cvs: ZendEngine2 / zend_execute.c
| From: | Zeev Suraski | Date: | Wed, 02 Jul 2003 17:48:19 +0000 |
| Subject: | cvs: ZendEngine2 / zend_execute.c | ||
| Groups: | php.zend-engine.cvs | ||
| Request: | Send a blank email to php-zend-engine-cvs+get-1436@lists.php.net to get a copy of this message | ||
zeev Wed Jul 2 13:48:19 2003 EDT
Modified files:
/ZendEngine2 zend_execute.c
Log:
Throughly fix scoping change. Fixes, among other things, bug #24403
Index: ZendEngine2/zend_execute.c
diff -u ZendEngine2/zend_execute.c:1.484 ZendEngine2/zend_execute.c:1.485
--- ZendEngine2/zend_execute.c:1.484 Wed Jul 2 11:06:10 2003
+++ ZendEngine2/zend_execute.c Wed Jul 2 13:48:18 2003
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_execute.c,v 1.484 2003/07/02 15:06:10 zeev Exp $ */
+/* $Id: zend_execute.c,v 1.485 2003/07/02 17:48:18 zeev Exp $ */
#define ZEND_INTENSIVE_DEBUGGING 0
@@ -2585,15 +2585,25 @@
zend_class_entry *current_scope;
zval *current_this;
int return_value_used = RETURN_VALUE_USED(EX(opline));
+ zend_bool should_change_scope;
zend_ptr_stack_n_push(&EG(argument_stack), 2, (void *) EX(opline)->extended_value, NULL);
EX_T(EX(opline)->result.u.var).var.ptr_ptr = &EX_T(EX(opline)->result.u.var).var.ptr;
- current_this = EG(This);
- EG(This) = EX(object);
- current_scope = EG(scope);
- EG(scope) = EX(calling_scope);
+ if (EX(function_state).function->type == ZEND_USER_FUNCTION
+ || EX(function_state).function->common.scope) {
+ should_change_scope = 1;
+ } else {
+ should_change_scope = 0;
+ }
+
+ if (should_change_scope) {
+ current_this = EG(This);
+ EG(This) = EX(object);
+ current_scope = EG(scope);
+ EG(scope) = EX(calling_scope);
+ }
if (EX(function_state).function->type == ZEND_INTERNAL_FUNCTION) {
ALLOC_ZVAL(EX_T(EX(opline)->result.u.var).var.ptr);
@@ -2668,11 +2678,14 @@
zval_ptr_dtor(&EX_T(EX(opline)->result.u.var).var.ptr);
}
}
- if (EG(This)) {
- zval_ptr_dtor(&EG(This));
+
+ if (should_change_scope) {
+ if (EG(This)) {
+ zval_ptr_dtor(&EG(This));
+ }
+ EG(This) = current_this;
+ EG(scope) = current_scope;
}
- EG(This) = current_this;
- EG(scope) = current_scope;
zend_ptr_stack_n_pop(&EG(arg_types_stack), 3, &EX(calling_scope), &EX(object),
&EX(fbc));
EX(function_state).function = (zend_function *) op_array;