xref: /PHP-7.3/ext/session/tests/bug71972.phpt (revision 05d53dee)
1--TEST--
2Bug #71972 (Cyclic references causing session_start(): Failed to decode session object)
3--SKIPIF--
4<?php include('skipif.inc'); ?>
5--INI--
6session.save_handler=files
7--FILE--
8<?php
9ob_start();
10session_start();
11
12$_SESSION['boogie'] = 1;
13
14$_SESSION['obj1'] = new stdClass();
15for ( $x=2; $x < 20; $x++) {
16	cyclic_ref($x);
17}
18
19function cyclic_ref($num) {
20	$_SESSION['obj'.$num] = new stdClass();
21	$_SESSION['obj'.$num]->test = new stdClass();//NOTE: No bug if try commenting out this too.
22	$_SESSION['obj'.$num]->obj1 = $_SESSION['obj1'];
23}
24
25var_dump(session_decode(session_encode()) == $_SESSION);
26?>
27--EXPECT--
28bool(true)
29