Req #60575 [NEW]: Provide a way to feed error_get_last() from custom error handler
| From: | alvaro at demogracia dot com | Date: | Tue, 20 Dec 2011 12:24:09 +0000 |
| Subject: | Req #60575 [NEW]: Provide a way to feed error_get_last() from custom error handler | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-165987@lists.php.net to get a copy of this message | ||
From:
Operating system:
PHP version: Irrelevant
Package: *General Issues
Bug Type: Feature/Change Request
Bug description:Provide a way to feed error_get_last() from custom error handler
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
--
Edit bug report at https://bugs.php.net/bug.php?id=60575&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=60575&r=trysnapshot54
Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=60575&r=trysnapshot53
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=60575&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=60575&r=fixed
Fixed in SVN and need be documented: https://bugs.php.net/fix.php?id=60575&r=needdocs
Fixed in release: https://bugs.php.net/fix.php?id=60575&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=60575&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=60575&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=60575&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=60575&r=support
Expected behavior: https://bugs.php.net/fix.php?id=60575&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=60575&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=60575&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=60575&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=60575&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=60575&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=60575&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=60575&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=60575&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=60575&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=60575&r=mysqlcfg