Req #44192 [Com]: set_error_handler is not being used on undefined functions

From: Date: Mon, 23 Jan 2017 13:26:53 +0000
Subject: Req #44192 [Com]: set_error_handler is not being used on undefined functions
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-206885@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=44192&edit=1

 ID:                 44192
 Comment by:         narf at devilix dot net
 Reported by:        kalle@php.net
 Summary:            set_error_handler is not being used on undefined
                     functions
 Status:             Open
 Type:               Feature/Change Request
 Package:            Feature/Change Request
 Operating System:   Windows XP (Build 2600)
 PHP Version:        5.2.5
 Block user comment: N
 Private report:     N

 New Comment:

As of PHP 7, an Error exception is thrown and then caught by set_exception_handler() callbacks.


Previous Comments:
------------------------------------------------------------------------
[2008-02-20 20:49:32] 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


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=44192&edit=1


Thread (3 messages)

« previous php.bugs (#206885) next »