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--EXPECTF-- 25Deprecated: %s implements the Serializable interface, which is deprecated. Implement __serialize() and __unserialize() instead (or in addition, if support for old PHP versions is necessary) in %s on line %d 26a:4:{i:0;N;i:1;N;i:2;s:6:"endcap";i:3;R:4;} 27array ( 28 0 => NULL, 29 1 => NULL, 30 2 => 'endcap', 31 3 => 'endcap', 32) 33