]> granicus.if.org Git - php/commitdiff
MFH: added error_get_last() function
authorMichael Wallner <mike@php.net>
Wed, 19 Jul 2006 12:25:46 +0000 (12:25 +0000)
committerMichael Wallner <mike@php.net>
Wed, 19 Jul 2006 12:25:46 +0000 (12:25 +0000)
NEWS
ext/standard/basic_functions.c
ext/standard/basic_functions.h
main/main.c
main/php_globals.h

diff --git a/NEWS b/NEWS
index 4187d7e30c145d0160017d5002ec8bc649fd827f..4037555e6effd506a9e95a0479adfc2937d4d838 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -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)
index c1a286660aa0354f68235b4632b5b825017c6920..d61cca8c5a450eba4b19e05790f3f5e6e7b59e98 100644 (file)
@@ -773,6 +773,10 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_error_log, 0, 0, 1)
        ZEND_ARG_INFO(0, extra_headers)
 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)
@@ -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)
index fcad4091b6d94f0d54f2719eca85324504a8b4ba..7c6fb9095b60f9b2cfeefbc79e91768f4169016d 100644 (file)
@@ -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);
index c7d41d9525f94847e1b7085697bd4096e614c80c..215a497dc5eb766cc5d194658d9fc0b0cfdb2a18 100644 (file)
@@ -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;
index 582a4722771e0c1d40d347aba2e2da472b73867a..d20ebb1ef73a159fe6ccb9383f2b3c4246378810 100644 (file)
@@ -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;