Edit report at https://bugs.php.net/bug.php?id=62672&edit=1
ID: 62672
Comment by: j dot henge-ernst at interexa dot de
Reported by: t dot weber at interexa dot de
Summary: Error on serialize of ArrayObject
Status: Open
Type: Bug
Package: SPL related
Operating System: Cent OS
PHP Version: 5.3.15
Block user comment: N
Private report: N
New Comment:
The problem is that the unserialize of ArrayIterator (and also maybe
ArrayObject or other SPL classes) can not dereference object references.
A simpler Testcase:
<?php
$x = new ArrayObject();
$t = array($x, $x->getIterator());
$s = serialize($t);
$e = unserialize($s);
Fatal error: Uncaught exception 'UnexpectedValueException' with message 'Error
at offset 13 of 26 bytes' in /tmp/test2.php:5
Stack trace:
#0 [internal function]: ArrayIterator->unserialize('x:i:16777216;r:...')
#1 /tmp/test2.php(5): unserialize('a:2:{i:0;C:11:"...')
#2 {main}
thrown in /tmp/test2.php on line 5
If the order in the array is reversed it works, as now the ArrayObject is only
a reference in the array.
Same behaviour with PHP 5.4.5
Previous Comments:
------------------------------------------------------------------------
[2012-07-27 11:04:48] t dot weber at interexa dot de
Description:
------------
Serialize and direct unserialize of Objects does not work if return value of
ArrayObject::getIterator is contained in parent class (see Test script)
Test script:
---------------
class ObjA
{
private $_varA;
public function __construct(Iterator $source)
{
$this->_varA = $source;
}
}
class ObjB extends ObjA
{
private $_varB;
public function __construct(ArrayObject $keys)
{
$this->_varB = $keys;
parent::__construct($keys->getIterator());
}
}
$obj = new ObjB(new ArrayObject());
unserialize(serialize($obj));
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=62672&edit=1