cvs: ZendEngine2(PHP_5_1) / zend_compile.h zend_vm_def.h zend_vm_execute.h zend_vm_execute.skl zend_vm_opcodes.h /tests bug33771.phpt
| From: | Antony Dovgal | Date: | Thu, 22 Sep 2005 19:03:19 +0000 |
| Subject: | cvs: ZendEngine2(PHP_5_1) / zend_compile.h zend_vm_def.h zend_vm_execute.h zend_vm_execute.skl zend_vm_opcodes.h /tests bug33771.phpt | ||
| Groups: | php.zend-engine.cvs | ||
| Request: | Send a blank email to php-zend-engine-cvs+get-4160@lists.php.net to get a copy of this message | ||
tony2001 Thu Sep 22 15:03:19 2005 EDT
Added files: (Branch: PHP_5_1)
/ZendEngine2/tests bug33771.phpt
Modified files:
/ZendEngine2 zend_compile.h zend_vm_def.h zend_vm_execute.h
zend_vm_execute.skl zend_vm_opcodes.h
Log:
MFH: fix #33771 (error_reporting falls to 0 when @ was used inside try/catch block)
http://cvs.php.net/diff.php/ZendEngine2/zend_compile.h?r1=1.316.2.3&r2=1.316.2.4&ty=u Index: ZendEngine2/zend_compile.h diff -u ZendEngine2/zend_compile.h:1.316.2.3 ZendEngine2/zend_compile.h:1.316.2.4 --- ZendEngine2/zend_compile.h:1.316.2.3 Fri Sep 16 13:05:08 2005 +++ ZendEngine2/zend_compile.h Thu Sep 22 15:03:15 2005 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_compile.h,v 1.316.2.3 2005/09/16 17:05:08 tony2001 Exp $ */ +/* $Id: zend_compile.h,v 1.316.2.4 2005/09/22 19:03:15 tony2001 Exp $ */ #ifndef ZEND_COMPILE_H #define ZEND_COMPILE_H @@ -294,6 +294,7 @@ zend_class_entry *calling_scope; HashTable *symbol_table; struct _zend_execute_data *prev_execute_data; + zval *old_error_reporting; }; #define EX(element) execute_data.element http://cvs.php.net/diff.php/ZendEngine2/zend_vm_def.h?r1=1.59.2.10&r2=1.59.2.11&ty=u Index: ZendEngine2/zend_vm_def.h diff -u ZendEngine2/zend_vm_def.h:1.59.2.10 ZendEngine2/zend_vm_def.h:1.59.2.11 --- ZendEngine2/zend_vm_def.h:1.59.2.10 Wed Sep 21 04:13:41 2005 +++ ZendEngine2/zend_vm_def.h Thu Sep 22 15:03:15 2005 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_vm_def.h,v 1.59.2.10 2005/09/21 08:13:41 derick Exp $ */ +/* $Id: zend_vm_def.h,v 1.59.2.11 2005/09/22 19:03:15 tony2001 Exp $ */ /* If you change this file, please regenerate the zend_vm_execute.h and * zend_vm_opcodes.h files by running: @@ -3449,7 +3449,11 @@ EX_T(opline->result.u.var).tmp_var.value.lval = EG(error_reporting); EX_T(opline->result.u.var).tmp_var.type = IS_LONG; /* shouldn't be necessary */ - zend_alter_ini_entry("error_reporting", sizeof("error_reporting"), "0", 1, ZEND_INI_USER, ZEND_INI_STAGE_RUNTIME); + EX(old_error_reporting) = &EX_T(opline->result.u.var).tmp_var; + + if (EG(error_reporting)) { + zend_alter_ini_entry("error_reporting", sizeof("error_reporting"), "0", 1, ZEND_INI_USER, ZEND_INI_STAGE_RUNTIME); + } ZEND_VM_NEXT_OPCODE(); } @@ -3464,13 +3468,14 @@ zend_op *opline = EX(opline); zval restored_error_reporting; - if (!EG(error_reporting)) { + if (!EG(error_reporting) && EX(old_error_reporting)->value.lval != 0) { restored_error_reporting.type = IS_LONG; restored_error_reporting.value.lval = EX_T(opline->op1.u.var).tmp_var.value.lval; convert_to_string(&restored_error_reporting); zend_alter_ini_entry("error_reporting", sizeof("error_reporting"), Z_STRVAL(restored_error_reporting), Z_STRLEN(restored_error_reporting), ZEND_INI_USER, ZEND_INI_STAGE_RUNTIME); zendi_zval_dtor(restored_error_reporting); } + EX(old_error_reporting) = NULL; ZEND_VM_NEXT_OPCODE(); } @@ -3597,6 +3602,7 @@ int i; int encapsulating_block=-1; zval **stack_zval_pp; + zval restored_error_reporting; stack_zval_pp = (zval **) EG(argument_stack).top_element - 1; while (*stack_zval_pp != NULL) { @@ -3624,6 +3630,16 @@ zend_ptr_stack_n_pop(&EG(arg_types_stack), 3, &EX(calling_scope), &EX(object), &EX(fbc)); } + /* restore previous error_reporting value */ + if (!EG(error_reporting) && EX(old_error_reporting) != NULL && EX(old_error_reporting)->value.lval != 0) { + restored_error_reporting.type = IS_LONG; + restored_error_reporting.value.lval = EX(old_error_reporting)->value.lval; + convert_to_string(&restored_error_reporting); + zend_alter_ini_entry("error_reporting", sizeof("error_reporting"), Z_STRVAL(restored_error_reporting), Z_STRLEN(restored_error_reporting), ZEND_INI_USER, ZEND_INI_STAGE_RUNTIME); + zendi_zval_dtor(restored_error_reporting); + } + EX(old_error_reporting) = NULL; + if (encapsulating_block == -1) { ZEND_VM_RETURN_FROM_EXECUTE_LOOP(); } else { http://cvs.php.net/diff.php/ZendEngine2/zend_vm_execute.h?r1=1.62.2.10&r2=1.62.2.11&ty=u Index: ZendEngine2/zend_vm_execute.h diff -u ZendEngine2/zend_vm_execute.h:1.62.2.10 ZendEngine2/zend_vm_execute.h:1.62.2.11 --- ZendEngine2/zend_vm_execute.h:1.62.2.10 Wed Sep 21 04:13:41 2005 +++ ZendEngine2/zend_vm_execute.h Thu Sep 22 15:03:15 2005 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_vm_execute.h,v 1.62.2.10 2005/09/21 08:13:41 derick Exp $ */ +/* $Id: zend_vm_execute.h,v 1.62.2.11 2005/09/22 19:03:15 tony2001 Exp $ */ static opcode_handler_t zend_user_opcode_handlers[256] = {(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL}; @@ -39,6 +39,7 @@ /* Initialize execute_data */ EX(fbc) = NULL; EX(object) = NULL; + EX(old_error_reporting) = NULL; if (op_array->T < TEMP_VAR_STACK_LIMIT) { EX(Ts) = (temp_variable *) do_alloca(sizeof(temp_variable) * op_array->T); } else { @@ -430,7 +431,11 @@ EX_T(opline->result.u.var).tmp_var.value.lval = EG(error_reporting); EX_T(opline->result.u.var).tmp_var.type = IS_LONG; /* shouldn't be necessary */ - zend_alter_ini_entry("error_reporting", sizeof("error_reporting"), "0", 1, ZEND_INI_USER, ZEND_INI_STAGE_RUNTIME); + EX(old_error_reporting) = &EX_T(opline->result.u.var).tmp_var; + + if (EG(error_reporting)) { + zend_alter_ini_entry("error_reporting", sizeof("error_reporting"), "0", 1, ZEND_INI_USER, ZEND_INI_STAGE_RUNTIME); + } ZEND_VM_NEXT_OPCODE(); } @@ -519,6 +524,7 @@ int i; int encapsulating_block=-1; zval **stack_zval_pp; + zval restored_error_reporting; stack_zval_pp = (zval **) EG(argument_stack).top_element - 1; while (*stack_zval_pp != NULL) { @@ -546,6 +552,16 @@ zend_ptr_stack_n_pop(&EG(arg_types_stack), 3, &EX(calling_scope), &EX(object), &EX(fbc)); } + /* restore previous error_reporting value */ + if (!EG(error_reporting) && EX(old_error_reporting) != NULL && EX(old_error_reporting)->value.lval != 0) { + restored_error_reporting.type = IS_LONG; + restored_error_reporting.value.lval = EX(old_error_reporting)->value.lval; + convert_to_string(&restored_error_reporting); + zend_alter_ini_entry("error_reporting", sizeof("error_reporting"), Z_STRVAL(restored_error_reporting), Z_STRLEN(restored_error_reporting), ZEND_INI_USER, ZEND_INI_STAGE_RUNTIME); + zendi_zval_dtor(restored_error_reporting); + } + EX(old_error_reporting) = NULL; + if (encapsulating_block == -1) { ZEND_VM_RETURN_FROM_EXECUTE_LOOP(); } else { @@ -4619,13 +4635,14 @@ zend_op *opline = EX(opline); zval restored_error_reporting; - if (!EG(error_reporting)) { + if (!EG(error_reporting) && EX(old_error_reporting)->value.lval != 0) { restored_error_reporting.type = IS_LONG; restored_error_reporting.value.lval = EX_T(opline->op1.u.var).tmp_var.value.lval; convert_to_string(&restored_error_reporting); zend_alter_ini_entry("error_reporting", sizeof("error_reporting"), Z_STRVAL(restored_error_reporting), Z_STRLEN(restored_error_reporting), ZEND_INI_USER, ZEND_INI_STAGE_RUNTIME); zendi_zval_dtor(restored_error_reporting); } + EX(old_error_reporting) = NULL; ZEND_VM_NEXT_OPCODE(); } http://cvs.php.net/diff.php/ZendEngine2/zend_vm_execute.skl?r1=1.2&r2=1.2.2.1&ty=u Index: ZendEngine2/zend_vm_execute.skl diff -u ZendEngine2/zend_vm_execute.skl:1.2 ZendEngine2/zend_vm_execute.skl:1.2.2.1 --- ZendEngine2/zend_vm_execute.skl:1.2 Wed Oct 27 21:19:33 2004 +++ ZendEngine2/zend_vm_execute.skl Thu Sep 22 15:03:17 2005 @@ -10,6 +10,7 @@ /* Initialize execute_data */ EX(fbc) = NULL; EX(object) = NULL; + EX(old_error_reporting) = NULL; if (op_array->T < TEMP_VAR_STACK_LIMIT) { EX(Ts) = (temp_variable *) do_alloca(sizeof(temp_variable) * op_array->T); } else { http://cvs.php.net/diff.php/ZendEngine2/zend_vm_opcodes.h?r1=1.42.2.8&r2=1.42.2.9&ty=u Index: ZendEngine2/zend_vm_opcodes.h diff -u ZendEngine2/zend_vm_opcodes.h:1.42.2.8 ZendEngine2/zend_vm_opcodes.h:1.42.2.9 --- ZendEngine2/zend_vm_opcodes.h:1.42.2.8 Wed Sep 21 04:13:43 2005 +++ ZendEngine2/zend_vm_opcodes.h Thu Sep 22 15:03:17 2005 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_vm_opcodes.h,v 1.42.2.8 2005/09/21 08:13:43 derick Exp $ */ +/* $Id: zend_vm_opcodes.h,v 1.42.2.9 2005/09/22 19:03:17 tony2001 Exp $ */ #define ZEND_NOP 0 #define ZEND_ADD 1 http://cvs.php.net/co.php/ZendEngine2/tests/bug33771.phpt?r=1.1&p=1 Index: ZendEngine2/tests/bug33771.phpt +++ ZendEngine2/tests/bug33771.phpt --TEST-- bug #33771 (error_reporting falls to 0 when @ was used inside try/catch block) --FILE-- <?php error_reporting(E_ALL | E_STRICT); var_dump(error_reporting()); function make_exception() { throw new Exception(); } function make_exception_and_change_err_reporting() { error_reporting(E_ALL); throw new Exception(); } try { @make_exception(); } catch (Exception $e) {} var_dump(error_reporting()); try { @make_exception_and_change_err_reporting(); } catch (Exception $e) {} var_dump(error_reporting()); echo "Done\n"; ?> --EXPECTF-- int(4095) int(4095) int(2047) Done
http://cvs.php.net/diff.php/ZendEngine2/zend_compile.h?r1=1.316.2.3&r2=1.316.2.4&ty=u Index: ZendEngine2/zend_compile.h diff -u ZendEngine2/zend_compile.h:1.316.2.3 ZendEngine2/zend_compile.h:1.316.2.4 --- ZendEngine2/zend_compile.h:1.316.2.3 Fri Sep 16 13:05:08 2005 +++ ZendEngine2/zend_compile.h Thu Sep 22 15:03:15 2005 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_compile.h,v 1.316.2.3 2005/09/16 17:05:08 tony2001 Exp $ */ +/* $Id: zend_compile.h,v 1.316.2.4 2005/09/22 19:03:15 tony2001 Exp $ */ #ifndef ZEND_COMPILE_H #define ZEND_COMPILE_H @@ -294,6 +294,7 @@ zend_class_entry *calling_scope; HashTable *symbol_table; struct _zend_execute_data *prev_execute_data; + zval *old_error_reporting; }; #define EX(element) execute_data.element http://cvs.php.net/diff.php/ZendEngine2/zend_vm_def.h?r1=1.59.2.10&r2=1.59.2.11&ty=u Index: ZendEngine2/zend_vm_def.h diff -u ZendEngine2/zend_vm_def.h:1.59.2.10 ZendEngine2/zend_vm_def.h:1.59.2.11 --- ZendEngine2/zend_vm_def.h:1.59.2.10 Wed Sep 21 04:13:41 2005 +++ ZendEngine2/zend_vm_def.h Thu Sep 22 15:03:15 2005 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_vm_def.h,v 1.59.2.10 2005/09/21 08:13:41 derick Exp $ */ +/* $Id: zend_vm_def.h,v 1.59.2.11 2005/09/22 19:03:15 tony2001 Exp $ */ /* If you change this file, please regenerate the zend_vm_execute.h and * zend_vm_opcodes.h files by running: @@ -3449,7 +3449,11 @@ EX_T(opline->result.u.var).tmp_var.value.lval = EG(error_reporting); EX_T(opline->result.u.var).tmp_var.type = IS_LONG; /* shouldn't be necessary */ - zend_alter_ini_entry("error_reporting", sizeof("error_reporting"), "0", 1, ZEND_INI_USER, ZEND_INI_STAGE_RUNTIME); + EX(old_error_reporting) = &EX_T(opline->result.u.var).tmp_var; + + if (EG(error_reporting)) { + zend_alter_ini_entry("error_reporting", sizeof("error_reporting"), "0", 1, ZEND_INI_USER, ZEND_INI_STAGE_RUNTIME); + } ZEND_VM_NEXT_OPCODE(); } @@ -3464,13 +3468,14 @@ zend_op *opline = EX(opline); zval restored_error_reporting; - if (!EG(error_reporting)) { + if (!EG(error_reporting) && EX(old_error_reporting)->value.lval != 0) { restored_error_reporting.type = IS_LONG; restored_error_reporting.value.lval = EX_T(opline->op1.u.var).tmp_var.value.lval; convert_to_string(&restored_error_reporting); zend_alter_ini_entry("error_reporting", sizeof("error_reporting"), Z_STRVAL(restored_error_reporting), Z_STRLEN(restored_error_reporting), ZEND_INI_USER, ZEND_INI_STAGE_RUNTIME); zendi_zval_dtor(restored_error_reporting); } + EX(old_error_reporting) = NULL; ZEND_VM_NEXT_OPCODE(); } @@ -3597,6 +3602,7 @@ int i; int encapsulating_block=-1; zval **stack_zval_pp; + zval restored_error_reporting; stack_zval_pp = (zval **) EG(argument_stack).top_element - 1; while (*stack_zval_pp != NULL) { @@ -3624,6 +3630,16 @@ zend_ptr_stack_n_pop(&EG(arg_types_stack), 3, &EX(calling_scope), &EX(object), &EX(fbc)); } + /* restore previous error_reporting value */ + if (!EG(error_reporting) && EX(old_error_reporting) != NULL && EX(old_error_reporting)->value.lval != 0) { + restored_error_reporting.type = IS_LONG; + restored_error_reporting.value.lval = EX(old_error_reporting)->value.lval; + convert_to_string(&restored_error_reporting); + zend_alter_ini_entry("error_reporting", sizeof("error_reporting"), Z_STRVAL(restored_error_reporting), Z_STRLEN(restored_error_reporting), ZEND_INI_USER, ZEND_INI_STAGE_RUNTIME); + zendi_zval_dtor(restored_error_reporting); + } + EX(old_error_reporting) = NULL; + if (encapsulating_block == -1) { ZEND_VM_RETURN_FROM_EXECUTE_LOOP(); } else { http://cvs.php.net/diff.php/ZendEngine2/zend_vm_execute.h?r1=1.62.2.10&r2=1.62.2.11&ty=u Index: ZendEngine2/zend_vm_execute.h diff -u ZendEngine2/zend_vm_execute.h:1.62.2.10 ZendEngine2/zend_vm_execute.h:1.62.2.11 --- ZendEngine2/zend_vm_execute.h:1.62.2.10 Wed Sep 21 04:13:41 2005 +++ ZendEngine2/zend_vm_execute.h Thu Sep 22 15:03:15 2005 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_vm_execute.h,v 1.62.2.10 2005/09/21 08:13:41 derick Exp $ */ +/* $Id: zend_vm_execute.h,v 1.62.2.11 2005/09/22 19:03:15 tony2001 Exp $ */ static opcode_handler_t zend_user_opcode_handlers[256] = {(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL}; @@ -39,6 +39,7 @@ /* Initialize execute_data */ EX(fbc) = NULL; EX(object) = NULL; + EX(old_error_reporting) = NULL; if (op_array->T < TEMP_VAR_STACK_LIMIT) { EX(Ts) = (temp_variable *) do_alloca(sizeof(temp_variable) * op_array->T); } else { @@ -430,7 +431,11 @@ EX_T(opline->result.u.var).tmp_var.value.lval = EG(error_reporting); EX_T(opline->result.u.var).tmp_var.type = IS_LONG; /* shouldn't be necessary */ - zend_alter_ini_entry("error_reporting", sizeof("error_reporting"), "0", 1, ZEND_INI_USER, ZEND_INI_STAGE_RUNTIME); + EX(old_error_reporting) = &EX_T(opline->result.u.var).tmp_var; + + if (EG(error_reporting)) { + zend_alter_ini_entry("error_reporting", sizeof("error_reporting"), "0", 1, ZEND_INI_USER, ZEND_INI_STAGE_RUNTIME); + } ZEND_VM_NEXT_OPCODE(); } @@ -519,6 +524,7 @@ int i; int encapsulating_block=-1; zval **stack_zval_pp; + zval restored_error_reporting; stack_zval_pp = (zval **) EG(argument_stack).top_element - 1; while (*stack_zval_pp != NULL) { @@ -546,6 +552,16 @@ zend_ptr_stack_n_pop(&EG(arg_types_stack), 3, &EX(calling_scope), &EX(object), &EX(fbc)); } + /* restore previous error_reporting value */ + if (!EG(error_reporting) && EX(old_error_reporting) != NULL && EX(old_error_reporting)->value.lval != 0) { + restored_error_reporting.type = IS_LONG; + restored_error_reporting.value.lval = EX(old_error_reporting)->value.lval; + convert_to_string(&restored_error_reporting); + zend_alter_ini_entry("error_reporting", sizeof("error_reporting"), Z_STRVAL(restored_error_reporting), Z_STRLEN(restored_error_reporting), ZEND_INI_USER, ZEND_INI_STAGE_RUNTIME); + zendi_zval_dtor(restored_error_reporting); + } + EX(old_error_reporting) = NULL; + if (encapsulating_block == -1) { ZEND_VM_RETURN_FROM_EXECUTE_LOOP(); } else { @@ -4619,13 +4635,14 @@ zend_op *opline = EX(opline); zval restored_error_reporting; - if (!EG(error_reporting)) { + if (!EG(error_reporting) && EX(old_error_reporting)->value.lval != 0) { restored_error_reporting.type = IS_LONG; restored_error_reporting.value.lval = EX_T(opline->op1.u.var).tmp_var.value.lval; convert_to_string(&restored_error_reporting); zend_alter_ini_entry("error_reporting", sizeof("error_reporting"), Z_STRVAL(restored_error_reporting), Z_STRLEN(restored_error_reporting), ZEND_INI_USER, ZEND_INI_STAGE_RUNTIME); zendi_zval_dtor(restored_error_reporting); } + EX(old_error_reporting) = NULL; ZEND_VM_NEXT_OPCODE(); } http://cvs.php.net/diff.php/ZendEngine2/zend_vm_execute.skl?r1=1.2&r2=1.2.2.1&ty=u Index: ZendEngine2/zend_vm_execute.skl diff -u ZendEngine2/zend_vm_execute.skl:1.2 ZendEngine2/zend_vm_execute.skl:1.2.2.1 --- ZendEngine2/zend_vm_execute.skl:1.2 Wed Oct 27 21:19:33 2004 +++ ZendEngine2/zend_vm_execute.skl Thu Sep 22 15:03:17 2005 @@ -10,6 +10,7 @@ /* Initialize execute_data */ EX(fbc) = NULL; EX(object) = NULL; + EX(old_error_reporting) = NULL; if (op_array->T < TEMP_VAR_STACK_LIMIT) { EX(Ts) = (temp_variable *) do_alloca(sizeof(temp_variable) * op_array->T); } else { http://cvs.php.net/diff.php/ZendEngine2/zend_vm_opcodes.h?r1=1.42.2.8&r2=1.42.2.9&ty=u Index: ZendEngine2/zend_vm_opcodes.h diff -u ZendEngine2/zend_vm_opcodes.h:1.42.2.8 ZendEngine2/zend_vm_opcodes.h:1.42.2.9 --- ZendEngine2/zend_vm_opcodes.h:1.42.2.8 Wed Sep 21 04:13:43 2005 +++ ZendEngine2/zend_vm_opcodes.h Thu Sep 22 15:03:17 2005 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_vm_opcodes.h,v 1.42.2.8 2005/09/21 08:13:43 derick Exp $ */ +/* $Id: zend_vm_opcodes.h,v 1.42.2.9 2005/09/22 19:03:17 tony2001 Exp $ */ #define ZEND_NOP 0 #define ZEND_ADD 1 http://cvs.php.net/co.php/ZendEngine2/tests/bug33771.phpt?r=1.1&p=1 Index: ZendEngine2/tests/bug33771.phpt +++ ZendEngine2/tests/bug33771.phpt --TEST-- bug #33771 (error_reporting falls to 0 when @ was used inside try/catch block) --FILE-- <?php error_reporting(E_ALL | E_STRICT); var_dump(error_reporting()); function make_exception() { throw new Exception(); } function make_exception_and_change_err_reporting() { error_reporting(E_ALL); throw new Exception(); } try { @make_exception(); } catch (Exception $e) {} var_dump(error_reporting()); try { @make_exception_and_change_err_reporting(); } catch (Exception $e) {} var_dump(error_reporting()); echo "Done\n"; ?> --EXPECTF-- int(4095) int(4095) int(2047) Done