php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #33771 error_reporting falls to 0 level after some try/catch block
Submitted: 2005-07-19 15:33 UTC Modified: 2005-09-22 21:05 UTC
From: s6urik at mail dot ee Assigned: tony2001
Status: Closed Package: Scripting Engine problem
PHP Version: 5.1.* (2005-07-30) OS: *
Private report: No CVE-ID:
 [2005-07-19 15:33 UTC] 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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-07-19 15:42 UTC] 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:48 UTC] tony2001@php.net
Dmitry, could you check it plz?
 [2005-07-21 12:21 UTC] 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-09-20 22:00 UTC] tony2001@php.net
Reassigned to myself so I won't forget to commit the patch..
 [2005-09-22 21:05 UTC] tony2001@php.net
Fixed in 5.1 and HEAD.
 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Sat Apr 19 09:02:28 2014 UTC