php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #68164 error_get_last() ignores silence operator
Submitted: 2014-10-06 13:04 UTC Modified: 2014-10-07 07:47 UTC
From: willem at mollie dot nl Assigned:
Status: Not a bug Package: Unknown/Other Function
PHP Version: 5.5.17 OS: N/A
Private report: No CVE-ID: None
 [2014-10-06 13:04 UTC] willem at mollie dot nl
Description:
------------
The function error_get_last() ignores the silence operator. Functions such as set_error_handler() received 0 as the value for the error type when the silence operator is used on the expression that triggered the error. However, error_get_last() does not.

This is rather inconsistent and makes it impossible to ignore errors when using error_get_last() for error handling (e.g. in a registered shutdown function).

Test script:
---------------
php -r '@1/0; print_r(error_get_last());'

Expected result:
----------------
PHP Warning:  Division by zero in Command line code on line 1
Array
(
    [type] => 0
    [message] => Division by zero
    [file] => Command line code
    [line] => 1
)

Actual result:
--------------
PHP Warning:  Division by zero in Command line code on line 1
Array
(
    [type] => 2
    [message] => Division by zero
    [file] => Command line code
    [line] => 1
)


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-10-06 18:55 UTC] nikic@php.net
-Status: Open +Status: Not a bug
 [2014-10-06 18:55 UTC] nikic@php.net
That's how it's supposed to work. When suppressing errors you still may want to retrieve information about it.
 [2014-10-07 07:47 UTC] willem at mollie dot nl
Thank you. I seems as though I was mistaken with the return value of error_reporting() when using a custom error handler. There does not seem to be any possibility of checking if the silence operator was used when using error_get_last() though (e.g. in a shutdown handler).
 [2015-02-16 20:07 UTC] marc at gutt dot it
Even its not a bug, its a missing feature. It would be really nice to know if an error was suppressed.
 [2015-05-26 16:46 UTC] chrisdmiddleton at gmail dot com
I'd like to echo the request for a way to check if the suppression operator was used. Perhaps it could be added as a key in the array returned by error_get_last?

E.g.

'suppressed' => true

Also, a related issue: the fact that error_get_last ignores the error_reporting level should be added to the documentation for both pages. Currently, this fact exists in a user comment on http://php.net/manual/en/function.error-get-last.php. But it should be noted officially, since many people don't read through the user comments.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun May 05 12:01:32 2024 UTC