Re: cvs: php4 / php.ini-dist php.ini-recommended /main main.c php_globals.h
| From: | Jani Taskinen | Date: | Sun, 07 Apr 2002 01:37:28 +0000 |
| Subject: | Re: cvs: php4 / php.ini-dist php.ini-recommended /main main.c php_globals.h | ||
| References: | 1 | Groups: | php.cvs |
| Request: | Send a blank email to php-cvs+get-10935@lists.php.net to get a copy of this message | ||
Please read README.CVS-RULES again for how to write correct
news entries.
--Jani
On Sat, 6 Apr 2002, Marcus Börger wrote:
>helly Sat Apr 6 13:50:01 2002 EDT
>
> Modified files:
> /php4/main main.c php_globals.h
> /php4 php.ini-dist php.ini-recommended
> Log:
> new feature ignoring repeated error messages (defaults to old behaviour)
> @You can now disable logging of repeated error messages with two new ini settings
> ignore_repeated_errors, ignore_repeated_source. @(Marcus)
>
>Index: php4/main/main.c
>diff -u php4/main/main.c:1.440 php4/main/main.c:1.441
>--- php4/main/main.c:1.440 Tue Mar 19 18:29:37 2002
>+++ php4/main/main.c Sat Apr 6 13:49:58 2002
>@@ -18,7 +18,7 @@
> +----------------------------------------------------------------------+
> */
>
>-/* $Id: main.c,v 1.440 2002/03/19 23:29:37 wez Exp $ */
>+/* $Id: main.c,v 1.441 2002/04/06 18:49:58 helly Exp $ */
>
> /* {{{ includes
> */
>@@ -84,6 +84,16 @@
> PHPAPI int core_globals_id;
> #endif
>
>+#define ERROR_BUF_LEN 1024
>+
>+typedef struct {
>+ char buf[ERROR_BUF_LEN];
>+ char filename[ERROR_BUF_LEN];
>+ uint lineno;
>+} last_error_type;
>+
>+static last_error_type last_error;
>+
> static void php_build_argv(char *s, zval *track_vars_array TSRMLS_DC);
>
>
>@@ -225,6 +235,8 @@
>
> STD_PHP_INI_BOOLEAN("ignore_user_abort", "0", PHP_INI_ALL, OnUpdateBool, ignore_user_abort, php_core_globals, core_globals)
>
> STD_PHP_INI_BOOLEAN("implicit_flush", "0", PHP_INI_PERDIR|PHP_INI_SYSTEM,OnUpdateBool, implicit_flush, php_core_globals, core_globals)
>
> STD_PHP_INI_BOOLEAN("log_errors", "0", PHP_INI_ALL, OnUpdateBool, log_errors, php_core_globals, core_globals)
>+ STD_PHP_INI_BOOLEAN("ignore_repeated_errors", "0", PHP_INI_ALL, OnUpdateBool, ignore_repeated_errors, php_core_globals, core_globals)
>+ STD_PHP_INI_BOOLEAN("ignore_repeated_source", "0", PHP_INI_ALL, OnUpdateBool, ignore_repeated_source, php_core_globals, core_globals)
>
> STD_PHP_INI_BOOLEAN("magic_quotes_gpc", "1", PHP_INI_ALL, OnUpdateBool, magic_quotes_gpc, php_core_globals, core_globals)
>
> STD_PHP_INI_BOOLEAN("magic_quotes_runtime", "0", PHP_INI_ALL, OnUpdateBool, magic_quotes_runtime, php_core_globals, core_globals)
>
> STD_PHP_INI_BOOLEAN("magic_quotes_sybase", "0", PHP_INI_ALL, OnUpdateBool, magic_quotes_sybase, php_core_globals, core_globals)
>@@ -408,8 +420,8 @@
> extended error handling function */
> static void php_error_cb(int type, const char *error_filename, const uint error_lineno, const
> char *format, va_list args)
> {
>- char buffer[1024];
>- int buffer_len;
>+ char buffer[ERROR_BUF_LEN];
>+ int buffer_len, display;
> TSRMLS_FETCH();
>
> buffer_len = vsnprintf(buffer, sizeof(buffer)-1, format, args);
>@@ -417,9 +429,24 @@
> if(buffer_len > sizeof(buffer) - 1 || buffer_len < 0) {
> buffer_len = sizeof(buffer) - 1;
> }
>+ if (PG(ignore_repeated_errors)) {
>+ if (strncmp(last_error.buf, buffer, sizeof(last_error.buf))
>+ || (!PG(ignore_repeated_source)
>+ && ((last_error.lineno != error_lineno)
>+ || strncmp(last_error.filename, error_filename, sizeof(last_error.filename))))) {
>+ display = 1;
>+ } else {
>+ display = 0;
>+ }
>+ } else {
>+ display = 1;
>+ }
>+ strlcpy(last_error.buf, buffer, sizeof(last_error.buf));
>+ strlcpy(last_error.filename, error_filename, sizeof(last_error.filename));
>+ last_error.lineno = error_lineno;
>
> /* display/log the error if necessary */
>- if ((EG(error_reporting) & type || (type & E_CORE))
>+ if (display && (EG(error_reporting) & type || (type & E_CORE))
> && (PG(log_errors) || PG(display_errors) || (!module_initialized))) {
> char *error_type_str;
>
>@@ -449,14 +476,14 @@
> }
>
> if (!module_initialized || PG(log_errors)) {
>- char log_buffer[1024];
>+ char log_buffer[ERROR_BUF_LEN];
>
> #ifdef PHP_WIN32
> if (type==E_CORE_ERROR || type==E_CORE_WARNING) {
> MessageBox(NULL, buffer, error_type_str, MB_OK|ZEND_SERVICE_MB_STYLE);
> }
> #endif
>- snprintf(log_buffer, 1024, "PHP %s: %s in %s on line %d", error_type_str, buffer,
>error_filename, error_lineno);
>+ snprintf(log_buffer, ERROR_BUF_LEN, "PHP %s: %s in %s on line %d",
>error_type_str, buffer, error_filename, error_lineno);
> php_log_err(log_buffer TSRMLS_CC);
> }
> if (module_initialized && PG(display_errors)
>@@ -469,8 +496,8 @@
> "<br />\n<b>%s</b>: %s in <b>%s</b> on line
> <b>%d</b><br />\n"
> : "\n%s: %s in %s on line %d\n";
> if (PG(xmlrpc_errors)) {
>- error_format = do_alloca(1024);
>- snprintf(error_format, 1023, "<?xml
>version=\"1.0\"?><methodResponse><fault><value><struct><member><name>faultCode</name><value><int>%ld</int></value></member><member><name>faultString</name><value><string>%%s:%%s
>in %%s on line
>%%d</string></value></member></struct></value></fault></methodResponse>",
>PG(xmlrpc_error_number));
>+ error_format = do_alloca(ERROR_BUF_LEN);
>+ snprintf(error_format, ERROR_BUF_LEN-1, "<?xml
>version=\"1.0\"?><methodResponse><fault><value><struct><member><name>faultCode</name><value><int>%ld</int></value></member><member><name>faultString</name><value><string>%%s:%%s
>in %%s on line
>%%d</string></value></member></struct></value></fault></methodResponse>",
>PG(xmlrpc_error_number));
> }
>
> if (prepend_string) {
>@@ -526,6 +553,7 @@
> }
>
> /* Log if necessary */
>+ if (!display) return;
> if (PG(track_errors) && EG(active_symbol_table)) {
> pval *tmp;
>
>Index: php4/main/php_globals.h
>diff -u php4/main/php_globals.h:1.75 php4/main/php_globals.h:1.76
>--- php4/main/php_globals.h:1.75 Mon Mar 18 13:57:25 2002
>+++ php4/main/php_globals.h Sat Apr 6 13:49:59 2002
>@@ -76,6 +76,8 @@
> zend_bool display_errors;
> zend_bool display_startup_errors;
> zend_bool log_errors;
>+ zend_bool ignore_repeated_errors;
>+ zend_bool ignore_repeated_source;
> char *error_log;
>
> char *doc_root;
>Index: php4/php.ini-dist
>diff -u php4/php.ini-dist:1.116 php4/php.ini-dist:1.117
>--- php4/php.ini-dist:1.116 Fri Mar 29 11:32:23 2002
>+++ php4/php.ini-dist Sat Apr 6 13:49:59 2002
>@@ -257,6 +257,15 @@
> ; error displaying on production web sites.
> log_errors = Off
>
>+; Do not log repeated messages. Repeated errors must occur in same file on same
>+; line until ignore_repeated_source is set true.
>+ignore_repeated_errors = Off
>+
>+; Ignore source of message when ignoring repeated messages. When this setting
>+; is On you will not log errors with repeated messages from different files or
>+; sourcelines.
>+ignore_repeated_source = Off
>+
> ; Store the last error/warning message in $php_errormsg (boolean).
> track_errors = Off
>
>Index: php4/php.ini-recommended
>diff -u php4/php.ini-recommended:1.69 php4/php.ini-recommended:1.70
>--- php4/php.ini-recommended:1.69 Fri Mar 29 11:32:23 2002
>+++ php4/php.ini-recommended Sat Apr 6 13:49:59 2002
>@@ -262,6 +262,15 @@
> ; error displaying on production web sites.
> log_errors = On
>
>+; Do not log repeated messages. Repeated errors must occur in same file on same
>+; line until ignore_repeated_source is set true.
>+ignore_repeated_errors = Off
>+
>+; Ignore source of message when ignoring repeated messages. When this setting
>+; is On you will not log errors with repeated messages from different files or
>+; sourcelines.
>+ignore_repeated_source = Off
>+
> ; Store the last error/warning message in $php_errormsg (boolean).
> track_errors = Off
>
>
>
>
>
--