PHP Bugs  
php.net | support | documentation | report a bug | advanced search | search howto | statistics | login

go to bug id or search bugs for  

Bug #44792 Serializing objects with protected members introduces null charcters
Submitted:21 Apr 2008 11:14am UTC Modified: 23 Jul 2008 9:26pm UTC
From:alex at fav dot or dot it Assigned to:helly
Status:Bogus Category:Scripting Engine problem
Version:5.2.5 OS:*
Votes:3 Avg. Score:3.7 ± 0.9 Reproduced:2 of 2 (100.0%)
Same Version:2 (100.0%) Same OS:1 (50.0%)
View/Vote Developer Edit Submission

[21 Apr 2008 11:14am UTC] alex at fav dot or dot it
Description:
------------
The output from the serialization of objects that contain protected (and
possibly private also) members contains null characters. These
characters are unnecessary and can cause problems when inserting the
serialized data into databases.

An asterisk is placed before the variable name in the serialized string,
which I assume is to mark it as protected. This asterisk is surrounded
by null characters.

This appears to be the same as the closed #29865 (closed 10/2005), but
in version 5.2.5 and the latest snapshot, the bug still exists.

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

Expected result:
----------------
The output should not contain null characters (shown as '00') around the
asterisk.

Actual result:
--------------
0000000 3a4f 3a33 4622 6f6f 3a22 3a31 737b 363a
0000010 223a 2a00 6200 7261 3b22 3a69 3b31 007d
000001f
[15 Jul 2008 5:22pm UTC] jani@php.net
Marcus, yet another PPP issue.
[21 Jul 2008 2:33pm UTC] penny at mjollnir dot org
Present in 5.2.6 as well.
[23 Jul 2008 9:26pm UTC] helly@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

That\'s just how PHP works. If you don\'t like the 0\'s then use
interface Serializable:

$> php --rc Serializable

RSS feed | show source 

PHP Copyright © 2001-2009 The PHP Group
All rights reserved.
Last updated: Sat Nov 21 10:30:49 2009 UTC