ID:               32545
 User updated by:  mailfrom-bugs dot php dot net at kopka dot net
 Reported By:      mailfrom-bugs dot php dot net at kopka dot net
 Status:           Open
-Bug Type:         Feature/Change Request
+Bug Type:         Scripting Engine problem
 Operating System: Gentoo
 PHP Version:      5.0.3
 New Comment:

The @include() also eats error messages for exceptions thrown inside
the included file which are not catched later on !

a.php
=====
<?php
class Test_Exception extends Exception {}
try [EMAIL PROTECTED]("b.php");}
catch (Test_Exception $e) {echo "Test_Exception thrown";}
echo "OK";
?>

b.php
=====
<?php
throw new Exception("something wrong");
?>


Expected result:
----------------
Fatal error: Uncaught exception 'Exception' with message 'something
wrong' in b.php:2
Stack trace:
#0 a.php(3): unknown()
#1 a.php(6): include_once('b.php)
#2 {main} thrown in b.php on line 2

Actual result:
--------------
OK


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

[2005-04-02 17:21:33] mailfrom-bugs dot php dot net at kopka dot net

Description:
------------
I don't know how to classify this so i leave it to someone who might
have a better idea how to deal with this:

BUG DESCRIPTION
===============

@include() supresses all error messages, INCLUDING PARSE ERRORS, in the
included script and all descendents.
This also affects __autoload so that there are no warnings whatsoever
when something goes wrong.
This makes a script using @include undebugable!


DOCUMENTATION PROBLEM
=====================
http://de2.php.net/manual/en/language.operators.errorcontrol.php states
that:
Note:  The "@" error-control operator prefix will not disable messages
that are the result of parse errors.

which is clearly wrong (see example).

It also states in the follwing warning:
Currently the "@" error-control operator prefix will even disable error
reporting for critical errors that will terminate script execution.
Among other things, this means that if you use "@" to suppress errors
from a certain function and either it isn't available or has been
mistyped, the script will die right there with no indication as to why.


which also quite misses the current behavior.

It seems to me that the current implementation of the @ operator is to
set error_reporting to E_NONE for the evaluation of the following
expression This is OK for something like
@list($a, $b, $c) = explode($sep, $string);
where it catches the 'Undefined offset' note. 

I ran into this doing the following:

if ([EMAIL PROTECTED]($path1.$filename))
{require_once($path2.$filename);}

wondering why the script terminates somewhere silently without giving a
notice about a reason.
After some hours of digging i found the error which aborted the script
and then traced the missing fatal back to the @include().


FEATURE REQUEST
===============

@ should modify error_reporting only for the current expression, and
not globally until the evaluation is complete.

RELATED
=======
Effect is also visible in example of Bug #31736


Reproduce code:
---------------
File include.php
------------------
<?php
@include("included.php");
?>

File included.php
------------------
<?php
[parse error of your choice]
?>


Expected result:
----------------
Parse error: parse error, unexpected [something] in included.php on
line 2

Actual result:
--------------
FATAL error message is supressed.



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


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

Reply via email to