Skip to content

bug 51363: var_export outputs an E_WARNING when recursion is detected #147

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion ext/standard/tests/general_functions/var_export_error2.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ var_export($obj, true);
===DONE===
--EXPECTF--

Fatal error: Nesting level too deep - recursive dependency? in %s on line 9
Warning: var_export does not handle circular references in %s on line 9
===DONE===
3 changes: 2 additions & 1 deletion ext/standard/tests/general_functions/var_export_error3.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ var_export($a, true);
===DONE===
--EXPECTF--

Fatal error: Nesting level too deep - recursive dependency? in %s on line 9
Warning: var_export does not handle circular references in %s on line 9
===DONE===
10 changes: 10 additions & 0 deletions ext/standard/var.c
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,11 @@ PHPAPI void php_var_export_ex(zval **struc, int level, smart_str *buf TSRMLS_DC)
break;
case IS_ARRAY:
myht = Z_ARRVAL_PP(struc);
if(myht && myht->nApplyCount > 0){
smart_str_appendl(buf, "NULL", 4);
zend_error(E_WARNING, "var_export does not handle circular references");
return;
}
if (level > 1) {
smart_str_appendc(buf, '\n');
buffer_append_spaces(buf, level - 1);
Expand All @@ -469,6 +474,11 @@ PHPAPI void php_var_export_ex(zval **struc, int level, smart_str *buf TSRMLS_DC)

case IS_OBJECT:
myht = Z_OBJPROP_PP(struc);
if(myht && myht->nApplyCount > 0){
smart_str_appendl(buf, "NULL", 4);
zend_error(E_WARNING, "var_export does not handle circular references");
return;
}
if (level > 1) {
smart_str_appendc(buf, '\n');
buffer_append_spaces(buf, level - 1);
Expand Down