From 4be862b02cb450f525d1aa8aafae4943cd1e47eb Mon Sep 17 00:00:00 2001 From: Zeev Suraski Date: Tue, 19 Nov 2002 17:51:30 +0000 Subject: [PATCH] MFZE1 - error_reporting fix --- Zend/zend.c | 24 ++++++++++++++++++++++++ Zend/zend.h | 1 + Zend/zend_builtin_functions.c | 6 +++--- Zend/zend_execute.c | 16 +++++++++++----- Zend/zend_execute_API.c | 2 -- 5 files changed, 39 insertions(+), 10 deletions(-) diff --git a/Zend/zend.c b/Zend/zend.c index 3901a46457..80c1b824a4 100644 --- a/Zend/zend.c +++ b/Zend/zend.c @@ -58,6 +58,22 @@ static void (*zend_message_dispatcher_p)(long message, void *data); static int (*zend_get_configuration_directive_p)(char *name, uint name_length, zval *contents); +static ZEND_INI_MH(OnUpdateErrorReporting) +{ + if (!new_value) { + EG(error_reporting) = E_ALL & ~E_NOTICE; + } else { + EG(error_reporting) = atoi(new_value); + } + return SUCCESS; +} + + +ZEND_INI_BEGIN() + ZEND_INI_ENTRY("error_reporting", NULL, ZEND_INI_ALL, OnUpdateErrorReporting) +ZEND_INI_END() + + #ifdef ZTS ZEND_API int compiler_globals_id; ZEND_API int executor_globals_id; @@ -508,6 +524,14 @@ int zend_startup(zend_utility_functions *utility_functions, char **extensions, i } +void zend_register_standard_ini_entries(TSRMLS_D) +{ + int module_number = 0; + + REGISTER_INI_ENTRIES(); +} + + #ifdef ZTS /* Unlink the global (r/o) copies of the class, function and constant tables, * and use a fresh r/w copy for the startup thread diff --git a/Zend/zend.h b/Zend/zend.h index e36ce7db0f..de97d15db3 100644 --- a/Zend/zend.h +++ b/Zend/zend.h @@ -396,6 +396,7 @@ typedef int (*zend_write_func_t)(const char *str, uint str_length); int zend_startup(zend_utility_functions *utility_functions, char **extensions, int start_builtin_functions); void zend_shutdown(TSRMLS_D); +void zend_register_standard_ini_entries(TSRMLS_D); #ifdef ZTS void zend_post_startup(TSRMLS_D); diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c index dd423366f1..3c09474391 100644 --- a/Zend/zend_builtin_functions.c +++ b/Zend/zend_builtin_functions.c @@ -22,7 +22,7 @@ #include "zend_API.h" #include "zend_builtin_functions.h" #include "zend_constants.h" - +#include "zend_ini.h" #undef ZEND_TEST_EXCEPTIONS static ZEND_FUNCTION(zend_version); @@ -408,8 +408,8 @@ ZEND_FUNCTION(error_reporting) if (zend_get_parameters_ex(1, &arg) == FAILURE) { RETURN_FALSE; } - convert_to_long_ex(arg); - EG(error_reporting)=(*arg)->value.lval; + 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); break; default: ZEND_WRONG_PARAM_COUNT(); diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c index 19a06deb01..a50ce095a2 100644 --- a/Zend/zend_execute.c +++ b/Zend/zend_execute.c @@ -31,6 +31,7 @@ #include "zend_extensions.h" #include "zend_fast_cache.h" #include "zend_execute_locks.h" +#include "zend_ini.h" #define get_zval_ptr(node, Ts, should_free, type) _get_zval_ptr(node, Ts, should_free TSRMLS_CC) #define get_zval_ptr_ptr(node, Ts, type) _get_zval_ptr_ptr(node, Ts TSRMLS_CC) @@ -3566,16 +3567,21 @@ int zend_exit_handler(ZEND_OPCODE_HANDLER_ARGS) int zend_begin_silence_handler(ZEND_OPCODE_HANDLER_ARGS) { - EX_T(EX(opline)->result.u.var).tmp_var.value.lval = EG(error_reporting); - EX_T(EX(opline)->result.u.var).tmp_var.type = IS_LONG; /* shouldn't be necessary */ - EG(error_reporting) = 0; + EX(Ts)[EX(opline)->result.u.var].tmp_var.value.lval = EG(error_reporting); + EX(Ts)[EX(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); NEXT_OPCODE(); } int zend_end_silence_handler(ZEND_OPCODE_HANDLER_ARGS) { - EG(error_reporting) = EX_T(EX(opline)->op1.u.var).tmp_var.value.lval; - NEXT_OPCODE(); + zval restored_error_reporting; + + restored_error_reporting.type = IS_LONG; + restored_error_reporting.value.lval = EX(Ts)[EX(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); } int zend_qm_assign_handler(ZEND_OPCODE_HANDLER_ARGS) diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c index 8814964269..933751168f 100644 --- a/Zend/zend_execute_API.c +++ b/Zend/zend_execute_API.c @@ -162,7 +162,6 @@ void init_executor(TSRMLS_D) zend_ptr_stack_init(&EG(user_error_handlers)); zend_ptr_stack_init(&EG(user_exception_handlers)); - EG(orig_error_reporting) = EG(error_reporting); zend_objects_store_init(&EG(objects_store), 1024); EG(full_tables_cleanup) = 0; @@ -251,7 +250,6 @@ void shutdown_executor(TSRMLS_D) zend_ptr_stack_clean(&EG(user_exception_handlers), ZVAL_DESTRUCTOR, 1); zend_ptr_stack_destroy(&EG(user_exception_handlers)); - EG(error_reporting) = EG(orig_error_reporting); zend_objects_store_destroy(&EG(objects_store)); } zend_end_try(); } -- 2.40.0