ID:               30346
 User updated by:  profic at kursknet dot ru
 Reported By:      profic at kursknet dot ru
 Status:           Open
 Bug Type:         Zend Engine 2 problem
 Operating System: WinXP
 PHP Version:      5.0.2
 New Comment:

Sorry, I forgot to mention that some times CLI version (which it was
tested on) it crashes. Not allways (e.g. with every code), but with the
same code it is reproducable. And with this code it crashes. But script
finishes, so it seems a crash at shutdown


Previous Comments:
------------------------------------------------------------------------

[2004-10-06 23:54:14] profic at kursknet dot ru

Description:
------------
Class inherited of class implemented ArrayAccess have problems with
using
$this['some' . $var] = $var . 'str';
if $var passed as method parameter.
Seems this is a memory problem.
Look at the 3 last entries in rtfHelperArray::haStore.

Reproduce code:
---------------
<?php
abstract class rtfHelperArray implements arrayAccess {
        private $haStore = array ();

        final public function offsetExists ($offset) {
                return true;
        }

        final public function offsetGet ($offset) {
                if (array_key_exists ($offset, $this->haStore)) {
                        return $this->haStore[$offset];
                } else {
                        $temp = NULL;
                        return $temp;
                }
        }

        final public function offsetSet ($offset, $value) {
                $this->haStore[$offset] = $value;
                return true;
        }

        final public function offsetUnset ($offset) {
                unset ($this->haStore[$offset]);
                return true;
        }
}

error_reporting (E_ALL);

class test extends rtfHelperArray {
        public function doTest ($idx) {
                $this[$idx] = $idx;
                echo $idx, ' : ', $this[$idx], "\n";
                $this[$idx . '-2'] = $idx . '-2';
                echo $idx . '-2', ' : ', $this[$idx . '-2'], "\n";
                $this['3-' . $idx] = $idx . '-333';
                echo '3-' . $idx, ' : ', $this['3-' . $idx], "\n";
                $this['4-' . $idx] = $idx . '-4444';
                echo '4-' . $idx, ' : ', $this['4-' . $idx], "\n";
                $this['5-' . $idx] = $idx . '-5';
                echo '5-' . $idx, ' : ', $this['5-' . $idx], "\n";
                var_dump ($this);
        }
}

$o = new test ();
$o->doTest ('idx');
?>

Expected result:
----------------
idx : idx
idx-2 : idx-2
3-idx : idx-333
4-idx : idx-4444
5-idx : idx-5
object(test)#1 (1) {
  ["haStore:private"]=>
  array(5) {
    ["idx"]=>
    string(3) "idx"
    ["idx-2"]=>
    string(5) "idx-2"
    ["3-idx"]=>
    string(7) "idx-333"
    ["4-idx"]=>
    string(8) "idx-4444"
    ["5-idx"]=>
    string(5) "idx-5"
  }
}

Actual result:
--------------
idx : idx
idx-2 : idx-2
3-idx :
4-idx : idx-4444
5-idx :
object(test)#1 (1) {
  ["haStore:private"]=>
  array(5) {
    ["idx"]=>
    string(3) "idx"
    ["idx-2"]=>
    string(5) "idx-2"
    ["idx-3"]=>
    string(7) "test  3"
    ["4-idx"]=>
    string(8) "idx-4444"
    ["idx-5"]=>
    string(5) "test "
  }
}


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=30346&edit=1

Reply via email to