It seems to me that the problem is that it hasn't parsed and executed the
auto_prepend_file before the parse error occurs in the main script.  Would
it be possible to execute the auto_prepend_file before parsing the main
script, or would that break functionality?
 
Steve Meyers
Build Manager
MyComputer.com
 
Our Tools.  Your Site.
 


-----Original Message-----
From: Steve Meyers 
Sent: Wednesday, February 21, 2001 2:40 PM
To: [EMAIL PROTECTED]
Subject: [PHP-DEV] PHP 4.0 Bug #9386: set_error_handler() doesn't always
catch errors


From:             [EMAIL PROTECTED]
Operating system: Red Hat Linux 6.2
PHP version:      4.0.4pl1
PHP Bug Type:     PHP options/info functions
Bug description:  set_error_handler() doesn't always catch errors

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 HANDLER\n";
}
 
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 "$hello\n";
}
 
?>
===================================

parse_error.php 
===================================
<?
 
thisisjunk();
 
?>
===================================


-- 
Edit Bug report at: http://bugs.php.net/?id=9386&edit=1



-- 
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]

-- 
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]

Reply via email to