Annotation of embedaddon/php/ext/standard/tests/serialize/bug64146.phpt, revision 1.1.1.1

1.1       misho       1: --TEST--
                      2: Bug #64146 (serialize incorrectly saving objects when they are cloned)
                      3: --FILE--
                      4: <?php
                      5: 
                      6: echo "Test\n";
                      7: 
                      8: class 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: 
                     19: class 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: 
                     39: class 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: 
                     51: print $a->a[0]->b->c . "\n";
                     52: print $a->a[1]->b->c . "\n";
                     53: 
                     54: ?>
                     55: Done
                     56: --EXPECT--
                     57: Test
                     58: 1
                     59: 2
                     60: Done

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>