]> granicus.if.org Git - php/commitdiff
Cleanup globals initialization
authorXinchen Hui <laruence@php.net>
Fri, 13 Feb 2015 02:58:35 +0000 (10:58 +0800)
committerXinchen Hui <laruence@php.net>
Fri, 13 Feb 2015 02:58:35 +0000 (10:58 +0800)
Zend/zend.c
ext/standard/browscap.c
main/main.c
sapi/fpm/fpm/fpm_main.c

index 1bd70ab292f5d81d888faaee172279d2171d2a59..bfa732c0d02e3b0700837b0bd9729a300465eddf 100644 (file)
@@ -466,22 +466,13 @@ static void compiler_globals_dtor(zend_compiler_globals *compiler_globals) /* {{
 static void executor_globals_ctor(zend_executor_globals *executor_globals) /* {{{ */
 {
        ZEND_TSRMLS_CACHE_UPDATE;
+       memset(executor_globals, 0, sizeof(*executor_globals));
+
        zend_startup_constants();
        zend_copy_constants(EG(zend_constants), GLOBAL_CONSTANTS_TABLE);
        zend_init_rsrc_plist();
        zend_init_exception_op();
-       EG(lambda_count) = 0;
-       ZVAL_UNDEF(&EG(user_error_handler));
-       ZVAL_UNDEF(&EG(user_exception_handler));
-       EG(in_autoload) = NULL;
-       EG(current_execute_data) = NULL;
-       EG(current_module) = NULL;
-       EG(exit_status) = 0;
-#if XPFPA_HAVE_CW
-       EG(saved_fpu_cw) = 0;
-#endif
-       EG(saved_fpu_cw_ptr) = NULL;
-       EG(active) = 0;
+       EG(error_reporting) = E_ALL & ~E_NOTICE;
 }
 /* }}} */
 
@@ -661,8 +652,7 @@ int zend_startup(zend_utility_functions *utility_functions, char **extensions) /
        ini_scanner_globals_ctor(&ini_scanner_globals);
        php_scanner_globals_ctor(&language_scanner_globals);
        zend_set_default_compile_time_values();
-       ZVAL_UNDEF(&EG(user_error_handler));
-       ZVAL_UNDEF(&EG(user_exception_handler));
+       EG(error_reporting) = E_ALL & ~E_NOTICE;
 #endif
 
        zend_interned_strings_init();
index 353e7cdccbf80dd665350aa1d962dc51607c283b..e88a09e883ca214f6437b6c05a9bec1339b990e9 100644 (file)
@@ -311,8 +311,7 @@ PHP_MINIT_FUNCTION(browscap) /* {{{ */
        char *browscap = INI_STR("browscap");
 
 #ifdef ZTS
-       ts_allocate_id(&browscap_globals_id, sizeof(browser_data),
-               (ts_allocate_ctor) browscap_globals_ctor, NULL);
+       ts_allocate_id(&browscap_globals_id, sizeof(browser_data), (ts_allocate_ctor) browscap_globals_ctor, NULL);
 #endif
        /* ctor call not really needed for non-ZTS */
 
index d5d101ae55bd6a0adafcdfd1afe5524041f5f626..d6b680c0be40f3e07e93f2682cd2787dedeb4dc5 100644 (file)
@@ -1919,8 +1919,6 @@ static size_t php_output_wrapper(const char *str, size_t str_length)
 static void core_globals_ctor(php_core_globals *core_globals)
 {
        memset(core_globals, 0, sizeof(*core_globals));
-
-       php_startup_ticks();
 }
 /* }}} */
 #endif
@@ -2035,9 +2033,7 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod
        char *php_os;
        zend_module_entry *module;
 #ifdef ZTS
-       zend_executor_globals *executor_globals;
        void ***tsrm_ls;
-       php_core_globals *core_globals;
 #endif
 
 #if defined(PHP_WIN32) || (defined(NETWARE) && defined(USE_WINSOCK))
@@ -2057,7 +2053,7 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod
        _CrtSetReportMode(_CRT_ASSERT, 0);
 #endif
 #else
-       php_os=PHP_OS;
+       php_os = PHP_OS;
 #endif
 
 #ifdef ZTS
@@ -2081,27 +2077,9 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod
 
        php_output_startup();
 
-       zuf.error_function = php_error_cb;
-       zuf.printf_function = php_printf;
-       zuf.write_function = php_output_wrapper;
-       zuf.fopen_function = php_fopen_wrapper_for_zend;
-       zuf.message_handler = php_message_handler_for_zend;
-       zuf.block_interruptions = sapi_module.block_interruptions;
-       zuf.unblock_interruptions = sapi_module.unblock_interruptions;
-       zuf.get_configuration_directive = php_get_configuration_directive_for_zend;
-       zuf.ticks_function = php_run_ticks;
-       zuf.on_timeout = php_on_timeout;
-       zuf.stream_open_function = php_stream_open_for_zend;
-       zuf.vspprintf_function = vspprintf;
-       zuf.vstrpprintf_function = vstrpprintf;
-       zuf.getenv_function = sapi_getenv;
-       zuf.resolve_path_function = php_resolve_path_for_zend;
-       zend_startup(&zuf, NULL);
-
 #ifdef ZTS
-       executor_globals = ts_resource(executor_globals_id);
        ts_allocate_id(&core_globals_id, sizeof(php_core_globals), (ts_allocate_ctor) core_globals_ctor, (ts_allocate_dtor) core_globals_dtor);
-       core_globals = ts_resource(core_globals_id);
+       php_startup_ticks();
 #ifdef PHP_WIN32
        ts_allocate_id(&php_win32_core_globals_id, sizeof(php_win32_core_globals), (ts_allocate_ctor) php_win32_core_globals_ctor, (ts_allocate_dtor) php_win32_core_globals_dtor);
 #endif
@@ -2122,24 +2100,23 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod
                }
        }
 #endif
-       EG(bailout) = NULL;
-       EG(error_reporting) = E_ALL & ~E_NOTICE;
-       PG(header_is_being_sent) = 0;
-       SG(request_info).headers_only = 0;
-       SG(request_info).argv0 = NULL;
-       SG(request_info).argc=0;
-       SG(request_info).argv=(char **)NULL;
-       PG(connection_status) = PHP_CONNECTION_NORMAL;
-       PG(during_request_startup) = 0;
-       PG(last_error_message) = NULL;
-       PG(last_error_file) = NULL;
-       PG(last_error_lineno) = 0;
-       EG(error_handling)  = EH_NORMAL;
-       EG(exception_class) = NULL;
-       PG(disable_functions) = NULL;
-       PG(disable_classes) = NULL;
-       EG(exception) = NULL;
-       EG(objects_store).object_buckets = NULL;
+
+       zuf.error_function = php_error_cb;
+       zuf.printf_function = php_printf;
+       zuf.write_function = php_output_wrapper;
+       zuf.fopen_function = php_fopen_wrapper_for_zend;
+       zuf.message_handler = php_message_handler_for_zend;
+       zuf.block_interruptions = sapi_module.block_interruptions;
+       zuf.unblock_interruptions = sapi_module.unblock_interruptions;
+       zuf.get_configuration_directive = php_get_configuration_directive_for_zend;
+       zuf.ticks_function = php_run_ticks;
+       zuf.on_timeout = php_on_timeout;
+       zuf.stream_open_function = php_stream_open_for_zend;
+       zuf.vspprintf_function = vspprintf;
+       zuf.vstrpprintf_function = vstrpprintf;
+       zuf.getenv_function = sapi_getenv;
+       zuf.resolve_path_function = php_resolve_path_for_zend;
+       zend_startup(&zuf, NULL);
 
 #if HAVE_SETLOCALE
        setlocale(LC_CTYPE, "");
index c4ebc8bd3b8a1c94749cfb6334f20c539c65ca74..8dde3775c17579fc4a536ce0204c882ed5596ef9 100644 (file)
@@ -629,7 +629,7 @@ void sapi_cgi_log_fastcgi(int level, char *message, size_t len)
 
 /* {{{ sapi_cgi_log_message
  */
-static void sapi_cgi_log_message(char *message)
+static void sapi_cgi_log_message(char *message TSRMLS_DC)
 {
        zlog(ZLOG_NOTICE, "PHP message: %s", message);
 }