1--TEST--
2Bug #80411: References to null-serialized object break serialize()
3--FILE--
4<?php
5
6class UnSerializable implements Serializable
7{
8  public function serialize() {}
9  public function unserialize($serialized) {}
10}
11
12$unser = new UnSerializable();
13$arr = [$unser];
14$arr[1] = &$arr[0];
15$arr[2] = 'endcap';
16$arr[3] = &$arr[2];
17
18$data = serialize($arr);
19echo $data . PHP_EOL;
20$recovered = unserialize($data);
21var_export($recovered);
22
23?>
24--EXPECT--
25a:4:{i:0;N;i:1;N;i:2;s:6:"endcap";i:3;R:4;}
26array (
27  0 => NULL,
28  1 => NULL,
29  2 => 'endcap',
30  3 => 'endcap',
31)
32