Annotation of embedaddon/php/Zend/tests/bug38220.phpt, revision 1.1.1.1

1.1       misho       1: --TEST--
                      2: Bug #38220 (Crash on some object operations)
                      3: --FILE--
                      4: <?php
                      5: class drv {
                      6:        public $obj;
                      7: 
                      8:        function func1() {
                      9:                echo "func1(): {$this->obj->i}\n";
                     10:        }
                     11: 
                     12:        function close() {
                     13:                echo "close(): {$this->obj->i}\n";
                     14:        }
                     15: }
                     16: 
                     17: class A {
                     18:        public $i;
                     19: 
                     20:        function __construct($i) {
                     21:                $this->i = $i;
                     22: 
                     23:        }
                     24: 
                     25:        function __call($method, $args) {
                     26:                $drv = myserv::drv();
                     27: 
                     28:                $drv->obj = $this;
                     29: 
                     30:                echo "before call $method\n";
                     31:                print_r($this);
                     32:                call_user_func_array(array($drv, $method), $args);
                     33:                echo "after call $method\n";
                     34: 
                     35:                // Uncomment this line to work without crash
                     36: //             $drv->obj = null;
                     37:        }
                     38: 
                     39:        function __destruct() {
                     40:                echo "A::__destruct()\n";
                     41:                $this->close();
                     42:        }
                     43: }
                     44: 
                     45: class myserv {
                     46:        private static $drv = null;
                     47: 
                     48:        static function drv() {
                     49:                if (is_null(self::$drv))
                     50:                        self::$drv = new drv;
                     51:                return self::$drv;
                     52:        }
                     53: }
                     54: 
                     55: $obj1 = new A(1);
                     56: $obj1->func1();
                     57: 
                     58: $obj2 = new A(2);
                     59: unset($obj1);
                     60: $obj2->func1();
                     61: ?>
                     62: --EXPECT--
                     63: before call func1
                     64: A Object
                     65: (
                     66:     [i] => 1
                     67: )
                     68: func1(): 1
                     69: after call func1
                     70: A::__destruct()
                     71: before call close
                     72: A Object
                     73: (
                     74:     [i] => 1
                     75: )
                     76: close(): 1
                     77: after call close
                     78: before call func1
                     79: A Object
                     80: (
                     81:     [i] => 2
                     82: )
                     83: func1(): 1
                     84: after call func1
                     85: A::__destruct()
                     86: before call close
                     87: A Object
                     88: (
                     89:     [i] => 2
                     90: )
                     91: close(): 2
                     92: after call close

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