From:             [EMAIL PROTECTED]
Operating system: RH 7.1
PHP version:      4.0CVS-2002-03-14
PHP Bug Type:     Variables related
Bug description:  Cannot unserialize() a string serialized with serialize()

Not sure if this is a bug but serialize() cannot work with arrays that
holds elements which points to the array itself

<?php
        $b=array(1,2,4);
  $b[]=&$b;
        $str=serialize($b);
        var_dump($b);
        var_dump($str);
        $c=unserialize($str);
        var_dump($c);
?>
The ouput is:
array(4) {
  [0]=>
  int(1)
  [1]=>
  int(2)
  [2]=>
  int(4)
  [3]=>
  *RECURSION*
}
string(64)
"a:4:{i:0;i:1;i:1;i:2;i:2;i:4;i:3;a:4:{i:0;i:1;i:1;i:2;i:2;i:4;}}"
bool(false)

If 
$b[]=&$b;
removed the output is:
array(3) {
  [0]=>
  int(1)
  [1]=>
  int(2)
  [2]=>
  int(4)
}
string(30) "a:3:{i:0;i:1;i:1;i:2;i:2;i:4;}"
array(3) {
  [0]=>
  int(1)
  [1]=>
  int(2)
  [2]=>
  int(4)
}
That's ok.
Serialize() have either to check against recursion or encode somehow the
recursion in the serialized(great BC impact).

-- 
Edit bug report at http://bugs.php.net/?id=16073&edit=1
-- 
Fixed in CVS:        http://bugs.php.net/fix.php?id=16073&r=fixedcvs
Fixed in release:    http://bugs.php.net/fix.php?id=16073&r=alreadyfixed
Need backtrace:      http://bugs.php.net/fix.php?id=16073&r=needtrace
Try newer version:   http://bugs.php.net/fix.php?id=16073&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=16073&r=support
Expected behavior:   http://bugs.php.net/fix.php?id=16073&r=notwrong
Not enough info:     http://bugs.php.net/fix.php?id=16073&r=notenoughinfo
Submitted twice:     http://bugs.php.net/fix.php?id=16073&r=submittedtwice

Reply via email to