cvs: ZendEngine2 / 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:05 +0000 |
| Subject: | cvs: ZendEngine2 / 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-4159@lists.php.net to get a copy of this message | ||
tony2001 Thu Sep 22 15:03:05 2005 EDT
Added files:
/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:
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.322&r2=1.323&ty=u Index: ZendEngine2/zend_compile.h diff -u ZendEngine2/zend_compile.h:1.322 ZendEngine2/zend_compile.h:1.323 --- ZendEngine2/zend_compile.h:1.322 Tue Aug 30 14:27:17 2005 +++ ZendEngine2/zend_compile.h Thu Sep 22 15:03:00 2005 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_compile.h,v 1.322 2005/08/30 18:27:17 helly Exp $ */ +/* $Id: zend_compile.h,v 1.323 2005/09/22 19:03:00 tony2001 Exp $ */ #ifndef ZEND_COMPILE_H #define ZEND_COMPILE_H @@ -299,6 +299,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.76&r2=1.77&ty=u Index: ZendEngine2/zend_vm_def.h diff -u ZendEngine2/zend_vm_def.h:1.76 ZendEngine2/zend_vm_def.h:1.77 --- ZendEngine2/zend_vm_def.h:1.76 Wed Sep 21 04:12:33 2005 +++ ZendEngine2/zend_vm_def.h Thu Sep 22 15:03:01 2005 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_vm_def.h,v 1.76 2005/09/21 08:12:33 derick Exp $ */ +/* $Id: zend_vm_def.h,v 1.77 2005/09/22 19:03:01 tony2001 Exp $ */ /* If you change this file, please regenerate the zend_vm_execute.h and * zend_vm_opcodes.h files by running: @@ -3589,7 +3589,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(); } @@ -3604,13 +3608,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(); } @@ -3737,6 +3742,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) { @@ -3764,6 +3770,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.79&r2=1.80&ty=u Index: ZendEngine2/zend_vm_execute.h diff -u ZendEngine2/zend_vm_execute.h:1.79 ZendEngine2/zend_vm_execute.h:1.80 --- ZendEngine2/zend_vm_execute.h:1.79 Wed Sep 21 04:12:33 2005 +++ ZendEngine2/zend_vm_execute.h Thu Sep 22 15:03:01 2005 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_vm_execute.h,v 1.79 2005/09/21 08:12:33 derick Exp $ */ +/* $Id: zend_vm_execute.h,v 1.80 2005/09/22 19:03:01 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 { @@ -439,7 +440,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(); } @@ -528,6 +533,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) { @@ -555,6 +561,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 { @@ -4770,13 +4786,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.3&ty=u Index: ZendEngine2/zend_vm_execute.skl diff -u ZendEngine2/zend_vm_execute.skl:1.2 ZendEngine2/zend_vm_execute.skl:1.3 --- ZendEngine2/zend_vm_execute.skl:1.2 Wed Oct 27 21:19:33 2004 +++ ZendEngine2/zend_vm_execute.skl Thu Sep 22 15:03:02 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.56&r2=1.57&ty=u Index: ZendEngine2/zend_vm_opcodes.h diff -u ZendEngine2/zend_vm_opcodes.h:1.56 ZendEngine2/zend_vm_opcodes.h:1.57 --- ZendEngine2/zend_vm_opcodes.h:1.56 Wed Sep 21 04:12:34 2005 +++ ZendEngine2/zend_vm_opcodes.h Thu Sep 22 15:03:02 2005 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_vm_opcodes.h,v 1.56 2005/09/21 08:12:34 derick Exp $ */ +/* $Id: zend_vm_opcodes.h,v 1.57 2005/09/22 19:03:02 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.322&r2=1.323&ty=u Index: ZendEngine2/zend_compile.h diff -u ZendEngine2/zend_compile.h:1.322 ZendEngine2/zend_compile.h:1.323 --- ZendEngine2/zend_compile.h:1.322 Tue Aug 30 14:27:17 2005 +++ ZendEngine2/zend_compile.h Thu Sep 22 15:03:00 2005 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_compile.h,v 1.322 2005/08/30 18:27:17 helly Exp $ */ +/* $Id: zend_compile.h,v 1.323 2005/09/22 19:03:00 tony2001 Exp $ */ #ifndef ZEND_COMPILE_H #define ZEND_COMPILE_H @@ -299,6 +299,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.76&r2=1.77&ty=u Index: ZendEngine2/zend_vm_def.h diff -u ZendEngine2/zend_vm_def.h:1.76 ZendEngine2/zend_vm_def.h:1.77 --- ZendEngine2/zend_vm_def.h:1.76 Wed Sep 21 04:12:33 2005 +++ ZendEngine2/zend_vm_def.h Thu Sep 22 15:03:01 2005 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_vm_def.h,v 1.76 2005/09/21 08:12:33 derick Exp $ */ +/* $Id: zend_vm_def.h,v 1.77 2005/09/22 19:03:01 tony2001 Exp $ */ /* If you change this file, please regenerate the zend_vm_execute.h and * zend_vm_opcodes.h files by running: @@ -3589,7 +3589,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(); } @@ -3604,13 +3608,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(); } @@ -3737,6 +3742,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) { @@ -3764,6 +3770,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.79&r2=1.80&ty=u Index: ZendEngine2/zend_vm_execute.h diff -u ZendEngine2/zend_vm_execute.h:1.79 ZendEngine2/zend_vm_execute.h:1.80 --- ZendEngine2/zend_vm_execute.h:1.79 Wed Sep 21 04:12:33 2005 +++ ZendEngine2/zend_vm_execute.h Thu Sep 22 15:03:01 2005 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_vm_execute.h,v 1.79 2005/09/21 08:12:33 derick Exp $ */ +/* $Id: zend_vm_execute.h,v 1.80 2005/09/22 19:03:01 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 { @@ -439,7 +440,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(); } @@ -528,6 +533,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) { @@ -555,6 +561,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 { @@ -4770,13 +4786,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.3&ty=u Index: ZendEngine2/zend_vm_execute.skl diff -u ZendEngine2/zend_vm_execute.skl:1.2 ZendEngine2/zend_vm_execute.skl:1.3 --- ZendEngine2/zend_vm_execute.skl:1.2 Wed Oct 27 21:19:33 2004 +++ ZendEngine2/zend_vm_execute.skl Thu Sep 22 15:03:02 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.56&r2=1.57&ty=u Index: ZendEngine2/zend_vm_opcodes.h diff -u ZendEngine2/zend_vm_opcodes.h:1.56 ZendEngine2/zend_vm_opcodes.h:1.57 --- ZendEngine2/zend_vm_opcodes.h:1.56 Wed Sep 21 04:12:34 2005 +++ ZendEngine2/zend_vm_opcodes.h Thu Sep 22 15:03:02 2005 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_vm_opcodes.h,v 1.56 2005/09/21 08:12:34 derick Exp $ */ +/* $Id: zend_vm_opcodes.h,v 1.57 2005/09/22 19:03:02 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