ID: 9386 Updated by: jmoore Reported By: [EMAIL PROTECTED] Old-Status: Open Status: Closed Bug Type: Scripting Engine problem Operating system: PHP Version: 4.0.4pl1 Assigned To: Comments: FATAL errors are not passed through user error handlers due to the fact the engine may be unstable and this could present security issues, instead the engine reports the error via its default mechanism as described in php.ini and then shutsdown as gracefully as possible. - James Previous Comments: --------------------------------------------------------------------------- [2001-02-21 16:39:35] [EMAIL PROTECTED] The files error_handler.inc, parse_error.php, and php_warning.php are included below. We have error_handler.inc as the auto_prepend_file in php.ini. It defines an error handling function and then sets it. However, when a parse error occurs, our error handler is not called, as you can see in the following snippet of execution. It is clear that the error handler is not being called in the second case. ******************************************* [httpd@dev10 php]$ php -q php_warning.php ERROR HANDLER [httpd@dev10 php]$ php -q parse_error.php <br> <b>Fatal error</b>: Call to undefined function: thisisjunk() in <b>parse_error.php</b> on line <b>3</b><br> [httpd@dev10 php]$ ******************************************* error_handler.inc ================================== <? /* >From php.ini: E_ALL - All errors and warnings E_ERROR - fatal run-time errors E_WARNING - run-time warnings (non fatal errors) E_PARSE - compile-time parse errors E_NOTICE - run-time notices (these are warnings which often result from a bug in your code, but it's possible that it was intentional (e.g., using an uninitialized variable and relying on the fact it's automatically initialized to an empty string) E_CORE_ERROR - fatal errors that occur during PHP's initial startup E_CORE_WARNING - warnings (non fatal errors) that occur during PHP's initial startup E_COMPILE_ERROR - fatal compile-time errors E_COMPILE_WARNING - compile-time warnings (non fatal errors) */ function myc_log_error($timeday, $message, $server, $level, $service, $script_name, $context) { echo "ERROR HANDLERn"; } function myc_error_handler($errno, $errstr, $errfile, $errline, $context) { switch($errno) { case E_NOTICE: case E_USER_NOTICE: case 0: // this occurs when the statement was prepended with an @ symbol // do nothing break; case E_WARNING: case E_CORE_WARNING: case E_COMPILE_WARNING: case E_USER_WARNING: myc_log_error(date("Y-m-d H:i:s"), $errstr, $GLOBALS['HOSTNAME'], $errno, $GLOBALS['SERVER_NAME'], $errfile, $context); break; default: myc_log_error(date("Y-m-d H:i:s"), $errstr, $GLOBALS['HOSTNAME'], $errno, $GLOBALS['SERVER_NAME'], $errfile, $context); header("Location: http://www.mycomputer.com/errors/error_available.html"); echo "Hello!n"; exit(); break; } } set_error_handler("myc_error_handler"); ?> ================================== php_warning.php ================================== <? foreach($arr as $hello) { echo "$hellon"; } ?> =================================== parse_error.php =================================== <? thisisjunk(); ?> =================================== --------------------------------------------------------------------------- ATTENTION! Do NOT reply to this email! To reply, use the web interface found at http://bugs.php.net/?id=9386&edit=2 -- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]