diff options
Diffstat (limited to 'main/main.c')
| -rw-r--r-- | main/main.c | 59 | 
1 files changed, 13 insertions, 46 deletions
diff --git a/main/main.c b/main/main.c index e1491db1fd..3a1e92ee08 100644 --- a/main/main.c +++ b/main/main.c @@ -1,7 +1,5 @@  /*     +----------------------------------------------------------------------+ -   | PHP Version 7                                                        | -   +----------------------------------------------------------------------+     | Copyright (c) The PHP Group                                          |     +----------------------------------------------------------------------+     | This source file is subject to version 3.01 of the PHP license,      | @@ -564,28 +562,28 @@ static PHP_INI_DISP(display_errors_mode)  PHPAPI const char *php_get_internal_encoding() {  	if (PG(internal_encoding) && PG(internal_encoding)[0]) {  		return PG(internal_encoding); -	} else if (SG(default_charset)) { +	} else if (SG(default_charset) && SG(default_charset)[0]) {  		return SG(default_charset);  	} -	return ""; +	return "UTF-8";  }  PHPAPI const char *php_get_input_encoding() {  	if (PG(input_encoding) && PG(input_encoding)[0]) {  		return PG(input_encoding); -	} else if (SG(default_charset)) { +	} else if (SG(default_charset) && SG(default_charset)[0]) {  		return SG(default_charset);  	} -	return ""; +	return "UTF-8";  }  PHPAPI const char *php_get_output_encoding() {  	if (PG(output_encoding) && PG(output_encoding)[0]) {  		return PG(output_encoding); -	} else if (SG(default_charset)) { +	} else if (SG(default_charset) && SG(default_charset)[0]) {  		return SG(default_charset);  	} -	return ""; +	return "UTF-8";  }  PHPAPI void (*php_internal_encoding_changed)(void) = NULL; @@ -731,7 +729,7 @@ PHP_INI_BEGIN()  	PHP_INI_ENTRY_EX("highlight.string",		HL_STRING_COLOR,	PHP_INI_ALL,	NULL,			php_ini_color_displayer_cb)  	STD_PHP_INI_ENTRY_EX("display_errors",		"1",		PHP_INI_ALL,		OnUpdateDisplayErrors,	display_errors,			php_core_globals,	core_globals, display_errors_mode) -	STD_PHP_INI_BOOLEAN("display_startup_errors",	"0",	PHP_INI_ALL,		OnUpdateBool,			display_startup_errors,	php_core_globals,	core_globals) +	STD_PHP_INI_BOOLEAN("display_startup_errors",	"1",	PHP_INI_ALL,		OnUpdateBool,			display_startup_errors,	php_core_globals,	core_globals)  	STD_PHP_INI_BOOLEAN("enable_dl",			"1",		PHP_INI_SYSTEM,		OnUpdateBool,			enable_dl,				php_core_globals,	core_globals)  	STD_PHP_INI_BOOLEAN("expose_php",			"1",		PHP_INI_SYSTEM,		OnUpdateBool,			expose_php,				php_core_globals,	core_globals)  	STD_PHP_INI_ENTRY("docref_root", 			"", 		PHP_INI_ALL,		OnUpdateString,			docref_root,			php_core_globals,	core_globals) @@ -753,7 +751,6 @@ PHP_INI_BEGIN()  	STD_PHP_INI_BOOLEAN("register_argc_argv",	"1",		PHP_INI_PERDIR|PHP_INI_SYSTEM,	OnUpdateBool,	register_argc_argv,		php_core_globals,	core_globals)  	STD_PHP_INI_BOOLEAN("auto_globals_jit",		"1",		PHP_INI_PERDIR|PHP_INI_SYSTEM,	OnUpdateBool,	auto_globals_jit,	php_core_globals,	core_globals)  	STD_PHP_INI_BOOLEAN("short_open_tag",	DEFAULT_SHORT_OPEN_TAG,	PHP_INI_SYSTEM|PHP_INI_PERDIR,		OnUpdateBool,			short_tags,				zend_compiler_globals,	compiler_globals) -	STD_PHP_INI_BOOLEAN("track_errors",			"0",		PHP_INI_ALL,		OnUpdateBool,			track_errors,			php_core_globals,	core_globals)  	STD_PHP_INI_ENTRY("unserialize_callback_func",	NULL,	PHP_INI_ALL,		OnUpdateString,			unserialize_callback_func,	php_core_globals,	core_globals)  	STD_PHP_INI_ENTRY("serialize_precision",	"-1",	PHP_INI_ALL,		OnSetSerializePrecision,			serialize_precision,	php_core_globals,	core_globals) @@ -1117,18 +1114,6 @@ PHPAPI ZEND_COLD void php_verror(const char *docref, const char *params, int typ  		efree(docref_buf);  	} -	if (PG(track_errors) && module_initialized && EG(active) && -			(Z_TYPE(EG(user_error_handler)) == IS_UNDEF || !(EG(user_error_handler_error_reporting) & type))) { -		zval tmp; -		ZVAL_STRINGL(&tmp, buffer, buffer_len); -		if (EG(current_execute_data)) { -			if (zend_set_local_var_str("php_errormsg", sizeof("php_errormsg")-1, &tmp, 0) == FAILURE) { -				zval_ptr_dtor(&tmp); -			} -		} else { -			zend_hash_str_update_ind(&EG(symbol_table), "php_errormsg", sizeof("php_errormsg")-1, &tmp); -		} -	}  	if (replace_buffer) {  		zend_string_free(replace_buffer);  	} else { @@ -1205,10 +1190,11 @@ PHPAPI void php_html_puts(const char *str, size_t size)  /* {{{ php_error_cb   extended error handling function */ -static ZEND_COLD void php_error_cb(int type, const char *error_filename, const uint32_t error_lineno, const char *format, va_list args) +static ZEND_COLD void php_error_cb(int orig_type, const char *error_filename, const uint32_t error_lineno, const char *format, va_list args)  {  	char *buffer;  	int buffer_len, display; +	int type = orig_type & E_ALL;  	buffer_len = (int)vspprintf(&buffer, PG(log_errors_max_len), format, args); @@ -1416,7 +1402,7 @@ static ZEND_COLD void php_error_cb(int type, const char *error_filename, const u  					sapi_header_op(SAPI_HEADER_REPLACE, &ctr);  				}  				/* the parser would return 1 (failure), we can bail out nicely */ -				if (type != E_PARSE) { +				if (!(orig_type & E_DONT_BAIL)) {  					/* restore memory limit */  					zend_set_memory_limit(PG(memory_limit));  					efree(buffer); @@ -1428,25 +1414,6 @@ static ZEND_COLD void php_error_cb(int type, const char *error_filename, const u  			break;  	} -	/* Log if necessary */ -	if (!display) { -		efree(buffer); -		return; -	} - -	if (PG(track_errors) && module_initialized && EG(active)) { -		zval tmp; - -		ZVAL_STRINGL(&tmp, buffer, buffer_len); -		if (EG(current_execute_data)) { -			if (zend_set_local_var_str("php_errormsg", sizeof("php_errormsg")-1, &tmp, 0) == FAILURE) { -				zval_ptr_dtor(&tmp); -			} -		} else { -			zend_hash_str_update_ind(&EG(symbol_table), "php_errormsg", sizeof("php_errormsg")-1, &tmp); -		} -	} -  	efree(buffer);  }  /* }}} */ @@ -1530,7 +1497,7 @@ PHP_FUNCTION(set_time_limit)  	zend_string *key;  	if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &new_timeout) == FAILURE) { -		return; +		RETURN_THROWS();  	}  	new_timeout_strlen = (int)zend_spprintf(&new_timeout_str, 0, ZEND_LONG_FMT, new_timeout); @@ -2363,13 +2330,12 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod  		struct {  			const long error_level;  			const char *phrase; -			const char *directives[17]; /* Remember to change this if the number of directives change */ +			const char *directives[18]; /* Remember to change this if the number of directives change */  		} directives[2] = {  			{  				E_DEPRECATED,  				"Directive '%s' is deprecated",  				{ -					"track_errors",  					"allow_url_include",  					NULL  				} @@ -2394,6 +2360,7 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod  					"safe_mode_allowed_env_vars",  					"safe_mode_protected_env_vars",  					"zend.ze1_compatibility_mode", +					"track_errors",  					NULL  				}  			}  | 
