1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00
Files
archived-php-src/ext/spl/tests/gh8044.phpt
Tyson Andre 8b9679e88e Make var_export/debug_zval_dump check for infinite recursion on the *object* (#9448)
Switch the recursion check from the result of `get_properties_for`
(the returned hash table of properties) to just checking for
infinite recursion on the object.

- In order for a native datastructure to correctly implement
  `*get_properties_for` for var_export's cycle detection,
  it would need to return the exact same array every time prior to this PR.

  Prior to this commit, the requirements for cycle detection
  would prevent SplFixedArray or similar classes from returning a
  temporary array that:

  1. Wouldn't be affected by unexpected mutations from error handlers
  2. Could be garbage collected instead.
2022-08-30 09:19:45 -04:00

21 lines
462 B
PHP

--TEST--
Bug GH-8044 (var_export/debug_zval_dump HT_ASSERT_RC1 debug failure for SplFixedArray)
--FILE--
<?php
call_user_func(function () {
$x = new SplFixedArray(1);
$x[0] = $x;
var_export($x); echo "\n";
debug_zval_dump($x); echo "\n";
});
?>
--EXPECTF--
Warning: var_export does not handle circular references in %s on line 5
\SplFixedArray::__set_state(array(
0 => NULL,
))
object(SplFixedArray)#2 (1) refcount(4){
[0]=>
*RECURSION*
}