Skip Menu |

This queue is for tickets about the PHP-Serialization CPAN distribution.

Report information
The Basics
Id: 45024
Status: resolved
Priority: 0/
Queue: PHP-Serialization

People
Owner: bobtfish [...] bobtfish.net
Requestors: admin-team [...] icdsoft.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in:
  • 0.25
  • 0.27
  • 0.28
  • 0.29
  • 0.30
Fixed in: (no value)



Subject: Serialization of booleans
Date: Tue, 14 Apr 2009 11:12:48 +0300
To: bug-PHP-Serialization [...] rt.cpan.org
From: Teodor Milkov <zimage [...] icdsoft.com>
Hi, We noticed that current versions of PHP::Serialization return 0 instead of undef for boolean data. In the following example: #!/usr/bin/perl use PHP::Serialization; use Data::Dumper; $s = 'a:4:{i:0;s:3:"ABC";i:1;s:3:"OPQ";i:2;s:3:"XYZ";i:3;b:0;}'; $u = PHP::Serialization::unserialize($s); print(Dumper($u)); we got the following output: $VAR1 = [ 'ABC', 'OPQ', 'XYZ', 0 ]; Isn't it supposed to be: $VAR1 = [ 'ABC', 'OPQ', 'XYZ', undef ]; Looks like the following patch is needed: --- lib/PHP/Serialization.pm 2004-02-23 16:48:40.000000000 -0500 +++ lib/PHP/Serialization.pm 2007-05-29 03:12:06.000000000 -0400 @@ -231,6 +231,9 @@ # Ok, read our boolen value.. my $bool = $self->_readchar(); $self->_skipchar(); # Toss the seperator + if ($bool eq '0') { + $bool = undef; + } push(@elems,$bool); } elsif ( $type eq 'undef' ) { # Ok, undef value.. -- Theodor Milkov ICDSoft Ltd. System Administrator http://www.icdsoft.com/
Download signature.asc
application/pgp-signature 260b

Message body not shown because it is not plain text.

I've just uploaded a 0.31 with your patch and a test case. However please also note that there are several other known and unfixed bugs in this code, and its not actively maintained (i.e. I'm not working to fix them). I'd recommend using JSON instead for production purposes. Cheers t0m