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: 2021-11-18 14:17 UTC
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: cmb (profile)
Status: Closed Package: *General Issues
PHP Version: 5.1.1 OS: gnu/linux, 2.6.14-1.1637_FC4
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
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

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-11-18 14:17 UTC] cmb@php.net
-Status: Open +Status: Closed -Package: Feature/Change Request +Package: *General Issues -Assigned To: +Assigned To: cmb
 [2021-11-18 14:17 UTC] cmb@php.net
As of PHP 8.0.0, set_error_handler() throws a TypeError exception
in case an invalid callback is given[1], so this ticket can be
closed.

[1] <https://3v4l.org/9Oebi>
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 09:01:29 2024 UTC