jani Tue Jul 24 14:21:37 2007 UTC
Modified files: (Branch: PHP_5_2)
/php-src NEWS php.ini-dist php.ini-recommended
/php-src/main main.c php_globals.h
Log:
MFH:- Changed "display_errors" php.ini option to accept "stderr" as value
which
MFH: makes the error messages to be outputted to STDERR instead of STDOUT
with
MFH: CGI and CLI SAPIs (FR #22839).
http://cvs.php.net/viewvc.cgi/php-src/NEWS?r1=1.2027.2.547.2.851&r2=1.2027.2.547.2.852&diff_format=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.2027.2.547.2.851 php-src/NEWS:1.2027.2.547.2.852
--- php-src/NEWS:1.2027.2.547.2.851 Tue Jul 24 11:39:55 2007
+++ php-src/NEWS Tue Jul 24 14:21:36 2007
@@ -12,6 +12,9 @@
- Enabled changing the size of statement cache for non-persistent OCI8
connections. (Chris Jones, Tony)
+- Changed "display_errors" php.ini option to accept "stderr" as value which
+ makes the error messages to be outputted to STDERR instead of STDOUT with
+ CGI and CLI SAPIs (FR #22839). (Jani)
- Changed error handler to send HTTP 500 instead of blank page on PHP errors.
(Dmitry, Andrei Nigmatulin)
- Changed mail() function to be always available. (Johannes)
http://cvs.php.net/viewvc.cgi/php-src/php.ini-dist?r1=1.231.2.10.2.20&r2=1.231.2.10.2.21&diff_format=u
Index: php-src/php.ini-dist
diff -u php-src/php.ini-dist:1.231.2.10.2.20
php-src/php.ini-dist:1.231.2.10.2.21
--- php-src/php.ini-dist:1.231.2.10.2.20 Thu Jun 21 09:02:21 2007
+++ php-src/php.ini-dist Tue Jul 24 14:21:36 2007
@@ -309,6 +309,16 @@
; instead (see below). Keeping display_errors enabled on a production web site
; may reveal security information to end users, such as file paths on your Web
; server, your database schema or other information.
+;
+; possible values for display_errors:
+;
+; Off - Do not display any errors
+; stderr - Display errors to STDERR (affects only CGI/CLI binaries!)
+;
+;display_errors = "stderr"
+;
+; stdout (On) - Display errors to STDOUT
+;
display_errors = On
; Even when display_errors is on, errors that occur during PHP's startup
http://cvs.php.net/viewvc.cgi/php-src/php.ini-recommended?r1=1.179.2.11.2.21&r2=1.179.2.11.2.22&diff_format=u
Index: php-src/php.ini-recommended
diff -u php-src/php.ini-recommended:1.179.2.11.2.21
php-src/php.ini-recommended:1.179.2.11.2.22
--- php-src/php.ini-recommended:1.179.2.11.2.21 Thu Jun 21 09:02:21 2007
+++ php-src/php.ini-recommended Tue Jul 24 14:21:36 2007
@@ -357,6 +357,18 @@
; instead (see below). Keeping display_errors enabled on a production web site
; may reveal security information to end users, such as file paths on your Web
; server, your database schema or other information.
+;
+; possible values for display_errors:
+;
+; Off - Do not display any errors
+; stderr - Display errors to STDERR (affects only CGI/CLI binaries!)
+; On or stdout - Display errors to STDOUT (default)
+;
+; To output errors to STDERR with CGI/CLI:
+;display_errors = "stderr"
+;
+; Default
+;
display_errors = Off
; Even when display_errors is on, errors that occur during PHP's startup
http://cvs.php.net/viewvc.cgi/php-src/main/main.c?r1=1.640.2.23.2.47&r2=1.640.2.23.2.48&diff_format=u
Index: php-src/main/main.c
diff -u php-src/main/main.c:1.640.2.23.2.47 php-src/main/main.c:1.640.2.23.2.48
--- php-src/main/main.c:1.640.2.23.2.47 Sat Jul 21 01:43:33 2007
+++ php-src/main/main.c Tue Jul 24 14:21:36 2007
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: main.c,v 1.640.2.23.2.47 2007/07/21 01:43:33 jani Exp $ */
+/* $Id: main.c,v 1.640.2.23.2.48 2007/07/24 14:21:36 jani Exp $ */
/* {{{ includes
*/
@@ -213,6 +213,89 @@
}
/* }}} */
+/* {{{ php_get_display_errors_mode() helper function
+ */
+static int php_get_display_errors_mode(char *value, int value_length)
+{
+ int mode;
+
+ if (value_length == 2 && !strcasecmp("on", value)) {
+ mode = PHP_DISPLAY_ERRORS_STDOUT;
+ } else if (value_length == 3 && !strcasecmp("yes", value)) {
+ mode = PHP_DISPLAY_ERRORS_STDOUT;
+ } else if (value_length == 4 && !strcasecmp("true", value)) {
+ mode = PHP_DISPLAY_ERRORS_STDOUT;
+ } else if (value_length == 6 && !strcasecmp(value, "stderr")) {
+ mode = PHP_DISPLAY_ERRORS_STDERR;
+ } else if (value_length == 6 && !strcasecmp(value, "stdout")) {
+ mode = PHP_DISPLAY_ERRORS_STDOUT;
+ } else {
+ mode = atoi(value);
+ if (mode && mode != PHP_DISPLAY_ERRORS_STDOUT && mode !=
PHP_DISPLAY_ERRORS_STDERR) {
+ mode = PHP_DISPLAY_ERRORS_STDOUT;
+ }
+ }
+ return mode;
+}
+/* }}} */
+
+/* {{{ PHP_INI_MH
+ */
+static PHP_INI_MH(OnUpdateDisplayErrors)
+{
+ PG(display_errors) = (zend_bool) php_get_display_errors_mode(new_value,
new_value_length);
+
+ return SUCCESS;
+}
+/* }}} */
+
+/* {{{ PHP_INI_DISP
+ */
+static PHP_INI_DISP(display_errors_mode)
+{
+ int mode, tmp_value_length, cgi_or_cli;
+ char *tmp_value;
+
+ if (type == ZEND_INI_DISPLAY_ORIG && ini_entry->modified) {
+ tmp_value = (ini_entry->orig_value ? ini_entry->orig_value :
NULL );
+ tmp_value_length = ini_entry->orig_value_length;
+ } else if (ini_entry->value) {
+ tmp_value = ini_entry->value;
+ tmp_value_length = ini_entry->value_length;
+ } else {
+ tmp_value = NULL;
+ tmp_value_length = 0;
+ }
+
+ mode = php_get_display_errors_mode(tmp_value, tmp_value_length);
+
+ /* Display 'On' for other SAPIs instead of STDOUT or STDERR */
+ cgi_or_cli = (!strcmp(sapi_module.name, "cli") ||
!strcmp(sapi_module.name, "cgi"));
+
+ switch (mode) {
+ case PHP_DISPLAY_ERRORS_STDERR:
+ if (cgi_or_cli ) {
+ PUTS("STDERR");
+ } else {
+ PUTS("On");
+ }
+ break;
+
+ case PHP_DISPLAY_ERRORS_STDOUT:
+ if (cgi_or_cli ) {
+ PUTS("STDOUT");
+ } else {
+ PUTS("On");
+ }
+ break;
+
+ default:
+ PUTS("Off");
+ break;
+ }
+}
+/* }}} */
+
/* Need to convert to strings and make use of:
* PHP_SAFE_MODE
*
@@ -246,7 +329,7 @@
STD_PHP_INI_BOOLEAN("allow_call_time_pass_reference", "1",
PHP_INI_SYSTEM|PHP_INI_PERDIR, OnUpdateBool,
allow_call_time_pass_reference, zend_compiler_globals, compiler_globals)
STD_PHP_INI_BOOLEAN("asp_tags", "0",
PHP_INI_SYSTEM|PHP_INI_PERDIR, OnUpdateBool,
asp_tags, zend_compiler_globals,
compiler_globals)
- STD_PHP_INI_BOOLEAN("display_errors", "1",
PHP_INI_ALL, OnUpdateBool, display_errors,
php_core_globals, core_globals)
+ 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("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)
@@ -809,7 +892,14 @@
php_printf("%s<br
/>\n<b>%s</b>: %s in <b>%s</b> on line <b>%d</b><br />\n%s",
STR_PRINT(prepend_string), error_type_str, buffer, error_filename,
error_lineno, STR_PRINT(append_string));
}
} else {
- php_printf("%s\n%s: %s in %s on line
%d\n%s", STR_PRINT(prepend_string), error_type_str, buffer, error_filename,
error_lineno, STR_PRINT(append_string));
+ /* Write CLI/CGI errors to stderr if
display_errors = "stderr" */
+ if ((!strcmp(sapi_module.name, "cli")
|| !strcmp(sapi_module.name, "cgi")) &&
+ PG(display_errors) ==
PHP_DISPLAY_ERRORS_STDERR
+ ) {
+ fprintf(stderr, "%s: %s in %s
on line %d\n", error_type_str, buffer, error_filename, error_lineno);
+ } else {
+ php_printf("%s\n%s: %s in %s on
line %d\n%s", STR_PRINT(prepend_string), error_type_str, buffer,
error_filename, error_lineno, STR_PRINT(append_string));
+ }
}
}
}
http://cvs.php.net/viewvc.cgi/php-src/main/php_globals.h?r1=1.98.2.1.2.6&r2=1.98.2.1.2.7&diff_format=u
Index: php-src/main/php_globals.h
diff -u php-src/main/php_globals.h:1.98.2.1.2.6
php-src/main/php_globals.h:1.98.2.1.2.7
--- php-src/main/php_globals.h:1.98.2.1.2.6 Mon Jul 9 17:27:23 2007
+++ php-src/main/php_globals.h Tue Jul 24 14:21:36 2007
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_globals.h,v 1.98.2.1.2.6 2007/07/09 17:27:23 dmitry Exp $ */
+/* $Id: php_globals.h,v 1.98.2.1.2.7 2007/07/24 14:21:36 jani Exp $ */
#ifndef PHP_GLOBALS_H
#define PHP_GLOBALS_H
@@ -33,7 +33,11 @@
extern ZEND_API struct _php_core_globals core_globals;
#endif
+/* Error display modes */
+#define PHP_DISPLAY_ERRORS_STDOUT 1
+#define PHP_DISPLAY_ERRORS_STDERR 2
+/* Track vars */
#define TRACK_VARS_POST 0
#define TRACK_VARS_GET 1
#define TRACK_VARS_COOKIE 2
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php