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

 ID:                 29865
 Comment by:         sdo at inbox dot lv
 Reported by:        ai...@php.net
 Summary:            serialize produces invalid output
 Status:             Closed
 Type:               Bug
 Package:            Strings related
 Operating System:   *
 PHP Version:        5CVS-2005-03-07
 Assigned To:        derick
 Block user comment: N
 Private report:     N

 New Comment:

Bug can still be reproduced in PHP 5.2 and 5.3



Example of running a simple test (orignally submitted by
ai...@php.net):



$ php -v

PHP 5.2.14 (cli) (built: Aug 12 2010 16:03:48)

$ php  -r 'class Foo { protected $bar = 1; } $v = new Foo; echo
serialize($v);' | hexdump

0000000 3a4f 3a33 4622 6f6f 3a22 3a31 737b 363a

0000010 223a 2a00 6200 7261 3b22 3a69 3b31 007d

000001f


Previous Comments:
------------------------------------------------------------------------
[2005-10-01 12:13:49] ai...@php.net

Yep, no problem in head.

------------------------------------------------------------------------
[2005-09-30 19:17:15] jhargis at gmail dot com

Can confirm this as being corrected and working in 5.0.5 as well.

------------------------------------------------------------------------
[2005-07-14 22:40:00] php dot net at sharpdreams dot com

Still busted in recent CVS, win32 & FreeBSD. Seems to work in 5.0.4.
This ought to be fixed before the next b3, or at least prior to release
of 5.1.

------------------------------------------------------------------------
[2005-01-22 13:57:12] ai...@php.net

This is still a problem in the latest head, simple test case:



$ ./php5_1 -r 'class Foo { protected $bar = 1; } $v = new Foo; echo
serialize($v);' | hexdump



0000000 3a4f 3a33 4622 6f6f 3a22 3a31 737b 363a

0000010 223a 2a00 6200 7261 3b22 3a69 3b31 007d

000001f

------------------------------------------------------------------------
[2005-01-06 20:23:42] jhargis at gmail dot com

I have noticed similar.  



<?php

class User {

  protected $username = "name";

  public function getU(){

    return $this->username;

  }

}



$ob_User = New User();

$wUser = serialize($ob_User);

echo $wUser;

$wUser2 = unserialize($wUser); 

echo $wUser2->getU() . "<br>\n";

?>



Protected/private members appear to have the 0x00 bytes around the
notation.  For the time, I base64 the serialized string so I can store
it in the DB without having to deal with it as a binary.  Also, this may
be related to why when using WDDX as the serialization handler it only
picks up the last member var when you need implement __sleep.

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


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    http://bugs.php.net/bug.php?id=29865


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

Reply via email to