ID:               41810
 User updated by:  d dot albano at gmail dot com
 Reported By:      d dot albano at gmail dot com
-Status:           Bogus
+Status:           Open
 Bug Type:         Feature/Change Request
 Operating System: Linux
 PHP Version:      5.2.3
 New Comment:

If there is a parse error, this error stop parsing of scripting engine,
and this is ok, but where is the problem? And why it should remain in an
unstable state? This doesn't make sense: it's parsing php code ... it
isin't executing it

If it remains in a unstable state there is serious problem somewhere :\


Previous Comments:
------------------------------------------------------------------------

[2007-06-26 11:49:38] [EMAIL PROTECTED]

After parse error the parser/compiler and whole engine may be in
unstable state, hence it's impossible to catch it as well as any other
fatal errors.
They are fatal errors just because of that.

------------------------------------------------------------------------

[2007-06-26 11:30:34] d dot albano at gmail dot com

As i've said:

> I understand that there isin't an easy way to do but a point of
start
> can be define it through htaccess/php_value or simply use it only
with
> included files after that set_error_handler is setted

Exactly for that reason: a file that is parsed can't rely on any
error_handler but if a file is included by another script that
initialize the error handler the stuff change becase the code is
executed normally and the file is included at runtime

Infact the code that i written refer exactly to this: check parse
errors on included files not on the main file.

It is normal that isn't possible to catch errors in main.php

------------------------------------------------------------------------

[2007-06-26 11:21:38] [EMAIL PROTECTED]

>it is something like a logical bug

It's something like a logical bug to catch parse errors using an error
handler defined in the same script, cause the parse error may happen in
the handler itself.
The parse error happens BEFORE execution starts, at the compilation
stage, so it's just phisically impossible to call something that does
not exist at that moment.

------------------------------------------------------------------------

[2007-06-26 10:46:51] d dot albano at gmail dot com

Description:
------------
Hi,

i've seen that set_error_handler doesn't let to the code to catch Parse
Errors. I know that set_error_handler documentation page on php manual
says that this error can't be catched, so this isin't a true bug: it is
something like a logical bug because using strange tricks you can catch
parse errors for included files.

So, instead to force php developers to do strange tricks to catch parse
errors why don't try to send parse errors throught user defined error
handler, if it is setted? I know that this isin't so simply but it is
becoming necessary: in an advanced system is vitally catch any kind of
error that can cause problem to page execution and this comprises
catching every kind of errors that can be generated by third party
module or every included file.

I understand that there isin't an easy way to do but a point of start
can be define it through htaccess/php_value or simply use it only with
included files after that set_error_handler is setted

Reproduce code:
---------------
# main.php:

<?php
function error_handler($errno, $errstr, $errfile, $errline)
{
    echo 'error catched!';
}

set_error_handler('error_handler');

require_once('file_with_parse_error.php');
?>

# file_with_parse_error.php:

<?php
--- this is a voluntary php parse error ---
?>


Expected result:
----------------
Browser should show:
error catched!

Actual result:
--------------
Browser output:
Parse error: syntax error, ....


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=41810&edit=1

Reply via email to