php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #44192 set_error_handler is not being used on undefined functions
Submitted: 2008-02-20 20:49 UTC Modified: 2017-01-23 13:48 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: kalle@php.net Assigned: nikic (profile)
Status: Closed Package: *General Issues
PHP Version: 5.2.5 OS: Windows XP (Build 2600)
Private report: No CVE-ID: None
 [2008-02-20 20:49 UTC] kalle@php.net
Description:
------------
When setting your own custom error handler and then calling an undefined function then the error handler isn't triggered.

I read on the manual that:
"If errors occur before the script is executed (e.g. on file uploads) the custom error handler cannot be called since it is not registered at that time."

But I would expect undefined function errors to be apart of the execution as a function might be created dynamiclly.

I also found bug '#11803' and read that fatal errors aren't passed to custom error handler functions, but It would be nice to be able to fetch such errors in larger applications.


Cheers

Reproduce code:
---------------
<?php
	function error_handler($errno, $errstr, $errfile = NULL, $errline = NULL, $errcontext = NULL)
	{
		var_dump($errno, $errstr, $errfile, $errline);

		return(true);
	}

	set_error_handler('error_handler');

	undef_function();

	/** Rest of the script */
?>

Expected result:
----------------
int(2)
string(28) "Call to undefined function undef_function()"
string(29) "/webserver/webroot/test.php"
int(11)

Actual result:
--------------
Fatal error: Call to undefined function undef_function() in /webserver/webroot/test.php on line 11

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-01-23 13:26 UTC] narf at devilix dot net
As of PHP 7, an Error exception is thrown and then caught by set_exception_handler() callbacks.
 [2017-01-23 13:48 UTC] nikic@php.net
-Status: Open +Status: Closed -Package: Feature/Change Request +Package: *General Issues -Assigned To: +Assigned To: nikic
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 17 05:01:31 2024 UTC