diff options
author | Michael Wallner <mike@php.net> | 2006-07-19 12:25:46 +0000 |
---|---|---|
committer | Michael Wallner <mike@php.net> | 2006-07-19 12:25:46 +0000 |
commit | 46f21b8a321b5f30c138c52c33717ef41fde52c0 (patch) | |
tree | 8a217b8d22fb3e268986102fd6b1b55deb3d43bd | |
parent | f7c99da2fead2169a581ea0a6850e3157a5276cc (diff) | |
download | php-git-46f21b8a321b5f30c138c52c33717ef41fde52c0.tar.gz |
MFH: added error_get_last() function
-rw-r--r-- | NEWS | 3 | ||||
-rw-r--r-- | ext/standard/basic_functions.c | 22 | ||||
-rw-r--r-- | ext/standard/basic_functions.h | 1 | ||||
-rw-r--r-- | main/main.c | 1 | ||||
-rw-r--r-- | main/php_globals.h | 1 |
5 files changed, 27 insertions, 1 deletions
@@ -7,7 +7,6 @@ PHP NEWS - Added support for Apache2Filter in the Windows build including binary support for both Apache 2.0.x (php5apache2_filter.dll) and Apache 2.2.x (php5apache2_2_filter.dll). (Edin) -- Added gmp_nextprime() function. (ants dot aasma at gmail dot com, Tony) - Updated timezonedb to version 2006.7. (Derick) - Changed priority of PHPRC environment variable on win32 to be higher then value from registry. (Dmitry) @@ -80,6 +79,8 @@ PHP NEWS - Added SimpleXMLElement::saveXML() as an alias for SimpleXMLElement::asXML(). (Hannes) - Added DOMNode::getNodePath() for getting an XPath for a node. (Christian) +- Added gmp_nextprime() function. (ants dot aasma at gmail dot com, Tony) +- Added error_get_last() function. (Mike) - Optimized zend_try/zend_catch macros by eliminating memcpy(3). (Dmitry) - Optimized require_once() and include_once() by eliminating fopen(3) diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index c1a286660a..d61cca8c5a 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -774,6 +774,10 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_error_log, 0, 0, 1) ZEND_END_ARG_INFO() static +ZEND_BEGIN_ARG_INFO_EX(arginfo_error_get_last, 0, 0, 0) +ZEND_END_ARG_INFO() + +static ZEND_BEGIN_ARG_INFO_EX(arginfo_call_user_func, 0, 0, 1) ZEND_ARG_INFO(0, function_name) ZEND_ARG_INFO(0, parmeter) @@ -3357,6 +3361,7 @@ zend_function_entry basic_functions[] = { PHP_FE(import_request_variables, arginfo_import_request_variables) PHP_FE(error_log, arginfo_error_log) + PHP_FE(error_get_last, arginfo_error_get_last) PHP_FE(call_user_func, arginfo_call_user_func) PHP_FE(call_user_func_array, arginfo_call_user_func_array) PHP_DEP_FE(call_user_method, arginfo_call_user_method) @@ -4957,6 +4962,23 @@ PHPAPI int _php_error_log(int opt_err, char *message, char *opt, char *headers T return SUCCESS; } +/* {{{ proto array error_get_last() + Get the last occurred error as associative array. Returns NULL if there hasn't been an error yet. */ +PHP_FUNCTION(error_get_last) +{ + if (ZEND_NUM_ARGS()) { + WRONG_PARAM_COUNT; + } + if (PG(last_error_message)) { + array_init(return_value); + add_assoc_long_ex(return_value, "type", sizeof("type"), PG(last_error_type)); + add_assoc_string_ex(return_value, "message", sizeof("message"), PG(last_error_message), 1); + add_assoc_string_ex(return_value, "file", sizeof("file"), PG(last_error_file)?PG(last_error_file):"-", 1 ); + add_assoc_long_ex(return_value, "line", sizeof("line"), PG(last_error_lineno)); + } +} +/* }}} */ + /* {{{ proto mixed call_user_func(string function_name [, mixed parmeter] [, mixed ...]) Call a user function which is the first parameter */ PHP_FUNCTION(call_user_func) diff --git a/ext/standard/basic_functions.h b/ext/standard/basic_functions.h index fcad4091b6..7c6fb9095b 100644 --- a/ext/standard/basic_functions.h +++ b/ext/standard/basic_functions.h @@ -79,6 +79,7 @@ PHP_FUNCTION(get_magic_quotes_gpc); PHP_FUNCTION(import_request_variables); PHP_FUNCTION(error_log); +PHP_FUNCTION(error_get_last); PHP_FUNCTION(call_user_func); PHP_FUNCTION(call_user_func_array); diff --git a/main/main.c b/main/main.c index c7d41d9525..215a497dc5 100644 --- a/main/main.c +++ b/main/main.c @@ -683,6 +683,7 @@ static void php_error_cb(int type, const char *error_filename, const uint error_ if (PG(last_error_file)) { free(PG(last_error_file)); } + PG(last_error_type) = type; PG(last_error_message) = strdup(buffer); PG(last_error_file) = strdup(error_filename); PG(last_error_lineno) = error_lineno; diff --git a/main/php_globals.h b/main/php_globals.h index 582a472277..d20ebb1ef7 100644 --- a/main/php_globals.h +++ b/main/php_globals.h @@ -142,6 +142,7 @@ struct _php_core_globals { zend_bool always_populate_raw_post_data; zend_bool report_zend_debug; + int last_error_type; char *last_error_message; char *last_error_file; int last_error_lineno; |