php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #35963 first call to set_error_handler returns same value on success and error
Submitted: 2006-01-10 16:35 UTC Modified: -
Votes:7
Avg. Score:4.1 ± 0.6
Reproduced:7 of 7 (100.0%)
Same Version:4 (57.1%)
Same OS:3 (42.9%)
From: jon at fuck dot org Assigned:
Status: Open Package: Feature/Change Request
PHP Version: 5.1.1 OS: gnu/linux, 2.6.14-1.1637_FC4
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2006-01-10 16:35 UTC] jon at fuck dot org
Description:
------------
the first call to set_error_handler returns NULL on success. on failure, e.g., if the desired callback function has not been declared, an E_WARNING is thrown and NULL is returned. this makes checking for failure of this function a little kludgy.

it would be better to always return FALSE on error, or, return the name of the internal PHP error handler on success, which is what our custom error handlers will be replacing on the first call.

by looking at previous bugs about this, it seems as though the documentation was right and the code was wrong.

Reproduce code:
---------------
<?
function foo() { echo 'foo'; }
echo (NULL === set_error_handler('foo'));
echo (NULL === set_error_handler('bar'));
?>

Expected result:
----------------
1foo

Actual result:
--------------
1foo1

Patches

Add a Patch

Pull Requests

Add a Pull Request

 
PHP Copyright © 2001-2018 The PHP Group
All rights reserved.
Last updated: Fri Nov 16 03:01:26 2018 UTC