Req #35963 [Opn->Csd]: first call to set_error_handler returns same value on success and error

From: Date: Thu, 18 Nov 2021 14:17:34 +0000
Subject: Req #35963 [Opn->Csd]: first call to set_error_handler returns same value on success and error
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-237850@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=35963&edit=1 ID: 35963 Updated by: cmb@php.net Reported by: jon at fuck dot org Summary: first call to set_error_handler returns same value on success and error -Status: Open +Status: Closed Type: Feature/Change Request -Package: Feature/Change Request +Package: *General Issues Operating System: gnu/linux, 2.6.14-1.1637_FC4 PHP Version: 5.1.1 -Assigned To: +Assigned To: cmb Block user comment: N Private report: N New Comment: 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> Previous Comments: ------------------------------------------------------------------------ [2006-01-10 16:35:29] 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 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=35963&edit=1

« previous php.bugs (#237850) next »