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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: jon at fuck dot org
New email:
PHP Version: OS:

 

 [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-2019 The PHP Group
All rights reserved.
Last updated: Fri Dec 06 13:01:23 2019 UTC