Fatal error raised by var_export() not caught by error handler
| Bug #51363 | Fatal error raised by var_export() not caught by error handler | |||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Submitted: | 2010-03-23 12:58 UTC | Modified: | 2012-08-06 04:01 UTC |
|
||||||||||
| From: | daan at react dot com | Assigned: | derick (profile) | |||||||||||
| Status: | Closed | Package: | Scripting Engine problem | |||||||||||
| PHP Version: | 5.2.13 | OS: | Debian Etch | |||||||||||
| Private report: | No | CVE-ID: | None | |||||||||||
[2010-03-23 12:58 UTC] daan at react dot com
Description:
------------
When a fatal error is raised by var_export() when trying to export a resursive array, it is not caught by a user php error handler.
Test script:
---------------
function myErrorHandler($errno, $errstr, $errfile, $errline)
{
var_dump($errno, $errstr, $errfile, $errline);
/* Don't execute PHP internal error handler */
return true;
}
set_error_handler("myErrorHandler");
$recursive = array();
$recursive[] = &$recursive;
var_export($recursive);
Expected result:
----------------
The var_dumped variables
Actual result:
--------------
array ( 0 => array ( 0 => array ( 0 => array ( 0 => array (
Fatal error: Nesting level too deep - recursive dependency? in test.php on line x
Patches
Pull Requests
History
AllCommentsChangesGit/SVN commits
[2010-03-23 14:16 UTC] derick@php.net
-Status: Open +Status: Assigned -Assigned To: +Assigned To: derick
[2010-04-22 22:37 UTC] whatrevolution at yahoo dot com
I am curious if the bug OP expects the var_export() output to never end... ever? I do, because it is a recursive reference, so I'm puzzled that this is considered a bug. However, perhaps the solution would be to not throw a fatal error, but throw a notice or warning and/or provide some way of telling var_export() how deep to print. array ( 0 => array ( 0 => array ( 0 => array ( 0 => array ( ( ! ) Fatal error: Nesting level too deep - recursive dependency? in /var/www/php_bugs/var_export_recursion_test.php on line 36 Call Stack # Time Memory Function Location 1 0.0004 108776 {main}( ) ../var_export_recursion_test.php:0 2 0.0004 109968 var_export ( ) ../var_export_recursion_test.php:36 PHP Version 5.2.10-2ubuntu6.4 System Linux 2.6.31-20-generic x86_64 Build Date Jan 6 2010 22:36:47 Server API Apache 2.0 Handler PHP API 20041225 PHP Extension 20060613 Zend Extension 220060519 Debug Build no Thread Safety disabled Zend Memory Manager enabled Apache/2.2.12 (Ubuntu)[2010-07-02 11:12 UTC] daan at react dot com
[2010-11-05 03:32 UTC] yohgaki at ohgaki dot net
[2012-08-06 04:00 UTC] stas@php.net
-Status: Assigned +Status: Closed
[2012-08-06 04:00 UTC] stas@php.net
[2012-08-06 04:01 UTC] stas@php.net