Index: Zend/zend_builtin_functions.c =================================================================== RCS file: /repository/ZendEngine2/zend_builtin_functions.c,v retrieving revision 1.277.2.5 diff -u -p -d -r1.277.2.5 zend_builtin_functions.c --- Zend/zend_builtin_functions.c 16 Sep 2005 17:05:06 -0000 1.277.2.5 +++ Zend/zend_builtin_functions.c 20 Sep 2005 19:24:53 -0000 @@ -425,6 +425,9 @@ ZEND_FUNCTION(error_reporting) } convert_to_string_ex(arg); zend_alter_ini_entry("error_reporting", sizeof("error_reporting"), Z_STRVAL_PP(arg), Z_STRLEN_PP(arg), ZEND_INI_USER, ZEND_INI_STAGE_RUNTIME); + if (EG(old_error_level_nesting)) { + EG(old_error_level) = atoi(Z_STRVAL_PP(arg)); + } break; default: ZEND_WRONG_PARAM_COUNT(); Index: Zend/zend_compile.h =================================================================== RCS file: /repository/ZendEngine2/zend_compile.h,v retrieving revision 1.316.2.3 diff -u -p -d -r1.316.2.3 zend_compile.h --- Zend/zend_compile.h 16 Sep 2005 17:05:08 -0000 1.316.2.3 +++ Zend/zend_compile.h 20 Sep 2005 19:24:53 -0000 @@ -294,6 +294,7 @@ struct _zend_execute_data { zend_class_entry *calling_scope; HashTable *symbol_table; struct _zend_execute_data *prev_execute_data; + zend_bool error_level_changed; }; #define EX(element) execute_data.element Index: Zend/zend_globals.h =================================================================== RCS file: /repository/ZendEngine2/zend_globals.h,v retrieving revision 1.141 diff -u -p -d -r1.141 zend_globals.h --- Zend/zend_globals.h 3 Aug 2005 13:30:52 -0000 1.141 +++ Zend/zend_globals.h 20 Sep 2005 19:24:53 -0000 @@ -233,6 +233,8 @@ struct _zend_executor_globals { zend_property_info std_property_info; void *reserved[ZEND_MAX_RESERVED_RESOURCES]; + long old_error_level; + long old_error_level_nesting; }; #include "zend_mm.h" Index: Zend/zend_vm_execute.h =================================================================== RCS file: /repository/ZendEngine2/zend_vm_execute.h,v retrieving revision 1.62.2.9 diff -u -p -d -r1.62.2.9 zend_vm_execute.h --- Zend/zend_vm_execute.h 19 Sep 2005 16:28:52 -0000 1.62.2.9 +++ Zend/zend_vm_execute.h 20 Sep 2005 19:24:55 -0000 @@ -39,6 +39,7 @@ ZEND_API void execute(zend_op_array *op_ /* Initialize execute_data */ EX(fbc) = NULL; EX(object) = NULL; + EX(error_level_changed) = 0; if (op_array->T < TEMP_VAR_STACK_LIMIT) { EX(Ts) = (temp_variable *) do_alloca(sizeof(temp_variable) * op_array->T); } else { @@ -313,6 +314,7 @@ static int ZEND_CATCH_SPEC_HANDLER(ZEND_ { zend_op *opline = EX(opline); zend_class_entry *ce; + zval restored_error_reporting; /* Check whether an exception has been thrown, if not, jump over code */ if (EG(exception) == NULL) { @@ -331,6 +333,18 @@ static int ZEND_CATCH_SPEC_HANDLER(ZEND_ } } + if (EX(error_level_changed) != 0) { + long error_level = EG(old_error_level); + + restored_error_reporting.type = IS_LONG; + restored_error_reporting.value.lval = error_level; + 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(error_level_changed) = 0; + } + EG(old_error_level_nesting)--; + zend_hash_update(EG(active_symbol_table), opline->op2.u.constant.value.str.val, opline->op2.u.constant.value.str.len+1, &EG(exception), sizeof(zval *), (void **) NULL); EG(exception) = NULL; @@ -426,11 +440,14 @@ static int ZEND_NEW_SPEC_HANDLER(ZEND_OP static int ZEND_BEGIN_SILENCE_SPEC_HANDLER(ZEND_OPCODE_HANDLER_ARGS) { - zend_op *opline = EX(opline); - - 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); + if (EG(old_error_level_nesting) == 0) { + EG(old_error_level) = EG(error_reporting); + } + if (EG(error_reporting) != 0) { + EX(error_level_changed) = 1; + zend_alter_ini_entry("error_reporting", sizeof("error_reporting"), "0", 1, ZEND_INI_USER, ZEND_INI_STAGE_RUNTIME); + } + EG(old_error_level_nesting)++; ZEND_VM_NEXT_OPCODE(); } @@ -4616,16 +4633,17 @@ static int ZEND_EXIT_SPEC_TMP_HANDLER(ZE static int ZEND_END_SILENCE_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS) { - zend_op *opline = EX(opline); zval restored_error_reporting; - if (!EG(error_reporting)) { + if (EX(error_level_changed) != 0) { restored_error_reporting.type = IS_LONG; - restored_error_reporting.value.lval = EX_T(opline->op1.u.var).tmp_var.value.lval; + restored_error_reporting.value.lval = EG(old_error_level); 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(error_level_changed) = 0; } + EG(old_error_level_nesting)--; ZEND_VM_NEXT_OPCODE(); }