com php-src: always export php_errormsg: main/main.c

From: Date: Thu, 12 Dec 2013 08:47:41 +0000
Subject: com php-src: always export php_errormsg: main/main.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-76647@lists.php.net to get a copy of this message
Commit: 4fd7f5833ca297098c33bacd01dcd81f3e780f0f Author: Antony Dovgal <tony@daylessday.org> Sat, 31 Dec 2011 00:51:32 +0400 Committer: Antony Dovgal <tony2001@php.net> Thu, 12 Dec 2013 12:47:41 +0400 Parents: d3d5222989409901449a42dee78cbe1549702c8d Branches: badoo-5..5_mysqlnd Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=4fd7f5833ca297098c33bacd01dcd81f3e780f0f Log: always export php_errormsg Changed paths: M main/main.c Diff: diff --git a/main/main.c b/main/main.c index 2f23935..adb44de 100644 --- a/main/main.c +++ b/main/main.c @@ -1135,6 +1135,51 @@ static void php_error_cb(int type, const char *error_filename, const uint error_ #endif } + /* + * export the php_errormsg valiable anyway, even if we're just about to bailout + * this allows userspace function to examine this string in function + * registered with register_shutdown_function() + * also this exports the variable even if error reporting is disabled + */ +#define DECLARE_NAMED_PVAL(var) \ + pval *var; \ + MAKE_STD_ZVAL(var); + +#define EXPORT_GLOBAL_PVAL(var, str) \ + zend_hash_update(&EG(symbol_table), str, sizeof(str), (void **)&var, sizeof(pval*), NULL); + + if (display && (EG(error_reporting) & type) && PG(track_errors)) + { + if (!EG(active_symbol_table)) { + zend_rebuild_symbol_table(TSRMLS_C); + } + + if (EG(active_symbol_table)) { + /* export error message */ + DECLARE_NAMED_PVAL(message); + ZVAL_STRINGL(message, buffer, buffer_len, 1); + EXPORT_GLOBAL_PVAL(message, "php_errormsg"); + + /* export error type */ + DECLARE_NAMED_PVAL(error_type); + ZVAL_LONG(error_type, type); + EXPORT_GLOBAL_PVAL(error_type, "php_error_type"); + + /* export filename */ + DECLARE_NAMED_PVAL(filename); + ZVAL_STRING(filename, (char *)error_filename, 1); + EXPORT_GLOBAL_PVAL(filename, "php_error_file"); + + /* export line number */ + DECLARE_NAMED_PVAL(lineno); + ZVAL_LONG(lineno, error_lineno); + EXPORT_GLOBAL_PVAL(lineno, "php_error_line"); + } + } + +#undef EXPORT_GLOBAL_PVAL +#undef DECLARE_NAMED_PVAL + /* Bail out if we can't recover */ switch (type) { case E_CORE_ERROR: @@ -1185,24 +1230,6 @@ static void php_error_cb(int type, const char *error_filename, const uint error_ } } - /* Log if necessary */ - if (!display) { - efree(buffer); - return; - } - - if (PG(track_errors) && module_initialized) { - if (!EG(active_symbol_table)) { - zend_rebuild_symbol_table(TSRMLS_C); - } - if (EG(active_symbol_table)) { - zval *tmp; - ALLOC_INIT_ZVAL(tmp); - ZVAL_STRINGL(tmp, buffer, buffer_len, 1); - zend_hash_update(EG(active_symbol_table), "php_errormsg", sizeof("php_errormsg"), (void **) & tmp, sizeof(zval *), NULL); - } - } - efree(buffer); } /* }}} */

« previous php.cvs (#76647) next »