#33771 [Asn]: error_reporting falls to 0 level after some try/catch block

From: Date: Tue, 20 Sep 2005 20:00:01 +0000
Subject: #33771 [Asn]: error_reporting falls to 0 level after some try/catch block
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-85300@lists.php.net to get a copy of this message
 ID:               33771
 Updated by:       tony2001@php.net
 Reported By:      s6urik at mail dot ee
 Status:           Assigned
 Bug Type:         Scripting Engine problem
 Operating System: *
 PHP Version:      5.1.* (2005-07-30)
-Assigned To:      dmitry
+Assigned To:      tony2001
 New Comment:

Reassigned to myself so I won't forget to commit the patch..


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

[2005-07-21 12:21:30] dmitry@php.net

The fix is near impossible with current implementation.
May be it could be fixed in future version of PHP with try/funally.
BTW, we decide not to include try/finally into PHP 5.1.

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

[2005-07-19 15:48:08] tony2001@php.net

Dmitry, could you check it plz?

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

[2005-07-19 15:42:40] derick@php.net

I'm not sure if we can qualify this as a bug actually. But atleast I
can offer an explanation. If you use @ the error reporting level will
be set to 0 before an expression (make_exception()) and set's it back
to the original value after it. Because the throwing of the exception
immediately jumps to the catch block, the error reporting level is not
reset back to it's old value. I'm not sure how easy this is to fix.

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

[2005-07-19 15:33:13] s6urik at mail dot ee

Description:
------------
If exception is throwed with error suppression (@) and catched by
try/catch block error_reporting will fall to 0

Reproduce code:
---------------
ini_set('display_errors', 1);
error_reporting(E_ALL | E_STRICT);

echo "1. error_reporting = " . error_reporting() . "\n";

function make_exception()
{
    throw new Exception();
}

try {
    @make_exception();
} catch (Exception $e) {}


echo "2. error_reporting = " . error_reporting() . "\n";

Expected result:
----------------
1. error_reporting = 4095
2. error_reporting = 4095


Actual result:
--------------
1. error_reporting = 4095
2. error_reporting = 0


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


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


Thread (6 messages)

« previous php.bugs (#85300) next »