php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #51362 var_export() second argument ignored on recursion fatal error
Submitted: 2010-03-23 12:40 UTC Modified: 2015-01-20 14:41 UTC
Votes:3
Avg. Score:5.0 ± 0.0
Reproduced:3 of 3 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (33.3%)
From: daan at react dot com Assigned: derick (profile)
Status: Not a bug Package: Output Control
PHP Version: 5.2.13 OS: Debian Etch
Private report: No CVE-ID: None
 [2010-03-23 12:40 UTC] daan at react dot com
Description:
------------
When calling var_export() on a recursive array, with the 'return' parameter set to true, a partial var_exported string is echoed and then a fatal error is raised. 
A more correct handling should be to just raise the php fatal error, not output the partial string. (sensitive data might be accidentally shown, for example)

Test script:
---------------
$recursive = array();
$recursive[] = &$recursive; 

$test = var_export($recursive, true);

Expected result:
----------------
Fatal error: Nesting level too deep - recursive dependency? in test.php on line x

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

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-03-23 14:16 UTC] derick@php.net
-Status: Open +Status: Assigned -Assigned To: +Assigned To: derick
 [2010-04-13 20:37 UTC] neel dot basu dot z at gmail dot com
Looks like similar to http://bugs.php.net/51533
 [2012-01-13 12:03 UTC] dduniec at go2 dot pl
I've just experience that error during debug on production environment. I've used 
it with debug_backtrace() var_export(debug_backtrace(), true) ... it outputs all 
information on the screen before nesting level error.
 [2015-01-19 23:12 UTC] derick@php.net
-Status: Assigned +Status: Not a bug
 [2015-01-19 23:12 UTC] derick@php.net
Thank you for taking the time to report a problem with PHP.
Unfortunately you are not using a current version of PHP -- 
the problem might already be fixed. Please download a new
PHP version from http://www.php.net/downloads.php

If you are able to reproduce the bug with one of the latest
versions of PHP, please change the PHP version on this bug report
to the version you tested and change the status back to "Open".
Again, thank you for your continued support of PHP.

I can not reproduce this with PHP 5.2.18 (or PHP 5.3.29 or later).
 [2015-01-20 14:41 UTC] daan at react dot com
It seems to have been fixed in the version after I reported it: (5.2.14) - http://3v4l.org/UUcqM
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 09:01:26 2024 UTC