php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #60575 Provide a way to feed error_get_last() from custom error handler
Submitted: 2011-12-20 12:24 UTC Modified: -
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: alvaro at demogracia dot com Assigned:
Status: Open Package: *General Issues
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
42 + 32 = ?
Subscribe to this entry?

 
 [2011-12-20 12:24 UTC] alvaro at demogracia dot com
Description:
------------
When you write a custom error handler to be used with set_error_handler(), the error_get_last() function is no longer usable (always returns NULL) unless you make your handler return FALSE (the internal variables required are filled by the builtin error handler).

There should be a mechanism to feed the required error info from custom error handler so error_get_last() can be made available.

Test script:
---------------
<?php
function custom_error_handler($errno, $errstr, $errfile, $errline){
    $ignore = ($errno & error_reporting()) == 0;
    if(!$ignore){
        echo "[Error happened: $errstr]\n";
    }
    return TRUE;
}
set_error_handler('custom_error_handler');

@fopen('xxx');
var_dump( error_get_last() ); // NULL

Expected result:
----------------
array(4) {
  ["type"]=>
  int(2)
  ["message"]=>
  string(46) "fopen() expects at least 2 parameters, 1 given"
  ["file"]=>
  string(15) "C:\tmp\test.php"
  ["line"]=>
  int(11)
}

Actual result:
--------------
NULL

Patches

Add a Patch

Pull Requests

Add a Pull Request

 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Tue Sep 17 09:01:26 2019 UTC