1--TEST-- 2Bug #64146 (serialize incorrectly saving objects when they are cloned) 3--FILE-- 4<?php 5 6echo "Test\n"; 7 8class A 9{ 10 public $a = array(); 11 12 public function __construct() 13 { 14 $this->a[] = new B(1); 15 $this->a[] = new B(2); 16 } 17} 18 19class B implements Serializable 20{ 21 public $b; 22 23 public function __construct($c) 24 { 25 $this->b = new C($c); 26 } 27 28 public function serialize() 29 { 30 return serialize(clone $this->b); 31 } 32 33 public function unserialize($data) 34 { 35 $this->b = unserialize($data); 36 } 37} 38 39class C 40{ 41 public $c; 42 43 public function __construct($c) 44 { 45 $this->c = $c; 46 } 47} 48 49$a = unserialize(serialize(new A())); 50 51print $a->a[0]->b->c . "\n"; 52print $a->a[1]->b->c . "\n"; 53 54?> 55Done 56--EXPECT-- 57Test 581 592 60Done 61