cvs: ZendEngine2 / zend_execute.c
| From: | Stanislav Malyshev | Date: | Thu, 14 Mar 2002 16:00:49 +0000 |
| Subject: | cvs: ZendEngine2 / zend_execute.c | ||
| Groups: | php.zend-engine.cvs | ||
| Request: | Send a blank email to php-zend-engine-cvs+get-20@lists.php.net to get a copy of this message | ||
stas Thu Mar 14 11:00:49 2002 EDT
Modified files:
/ZendEngine2 zend_execute.c
Log:
fix for delete $this and unset $this
Index: ZendEngine2/zend_execute.c
diff -u ZendEngine2/zend_execute.c:1.333 ZendEngine2/zend_execute.c:1.334
--- ZendEngine2/zend_execute.c:1.333 Tue Mar 12 13:53:27 2002
+++ ZendEngine2/zend_execute.c Thu Mar 14 11:00:48 2002
@@ -2813,29 +2813,44 @@
zval **object;
zend_bool unset_object;
- if (variable->type != IS_STRING) {
- tmp = *variable;
- zval_copy_ctor(&tmp);
- convert_to_string(&tmp);
- variable = &tmp;
- }
-
+
unset_object = (EX(opline)->extended_value == ZEND_UNSET_OBJ);
-
- if (unset_object) {
- if (zend_hash_find(EG(active_symbol_table), variable->value.str.val,
variable->value.str.len+1, (void **)&object) == FAILURE) {
- zend_error(E_ERROR, "Cannot delete non-existing object");
+ if (EX(opline)->op2.u.EA.type == ZEND_FETCH_THIS) {
+ if (!EG(This)) {
+ zend_error(E_WARNING, "Using $this in non-object context");
+ } else {
+ object = &EG(This);
+ if(unset_object) {
+ Z_OBJ_HT_PP(object)->delete_obj((*object));
+ zval_ptr_dtor(&EG(This));
+ EG(This) = NULL;
+ } else {
+ zend_error(E_WARNING, "$this cannot be unset");
+ }
+ }
+ } else {
+ if (variable->type != IS_STRING) {
+ tmp = *variable;
+ zval_copy_ctor(&tmp);
+ convert_to_string(&tmp);
+ variable = &tmp;
}
- if (Z_TYPE_PP(object) != IS_OBJECT) {
+
+ if (unset_object) {
+ if (zend_hash_find(EG(active_symbol_table), variable->value.str.val,
variable->value.str.len+1, (void **)&object) == FAILURE) {
+ zend_error(E_ERROR, "Cannot delete non-existing object");
+ }
+ if (Z_TYPE_PP(object) != IS_OBJECT) {
zend_error(E_ERROR, "Cannot call delete on non-object type");
+ }
+ Z_OBJ_HT_PP(object)->delete_obj((*object));
}
- Z_OBJ_HT_PP(object)->delete_obj((*object));
- }
- zend_hash_del(EG(active_symbol_table), variable->value.str.val,
variable->value.str.len+1);
+ zend_hash_del(EG(active_symbol_table), variable->value.str.val,
variable->value.str.len+1);
- if (variable == &tmp) {
- zval_dtor(&tmp);
+ if (variable == &tmp) {
+ zval_dtor(&tmp);
+ }
}
FREE_OP(EX(Ts), &EX(opline)->op1, EG(free_op1));
}