Req #16073 [Opn->Bgs]: Cannot unserialize() a string serialized with serialize()

From: Date: Fri, 31 Dec 2010 23:34:03 +0000
Subject: Req #16073 [Opn->Bgs]: Cannot unserialize() a string serialized with serialize()
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-157445@lists.php.net to get a copy of this message
Edit report at http://bugs.php.net/bug.php?id=16073&edit=1

 ID:                 16073
 Updated by:         jani@php.net
 Reported by:        ahristov at icygen dot com
 Summary:            Cannot unserialize() a string serialized with
                     serialize()
-Status:             Open
+Status:             Bogus
 Type:               Feature/Change Request
-Package:            Feature/Change Request
+Package:            *General Issues
 Operating System:   RH 7.1
 PHP Version:        4.0CVS-2002-03-14
 Block user comment: N
 Private report:     N

 New Comment:

AFAIK, this was some bug that got fixed.


Previous Comments:
------------------------------------------------------------------------
[2002-03-14 10:20:54] ahristov at icygen dot com

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 this bug report at http://bugs.php.net/bug.php?id=16073&edit=1


Thread (3 messages)

« previous php.bugs (#157445) next »