Skip Menu |

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

Report information
The Basics
Id: 97863
Status: new
Priority: 0/
Queue: PHP-Serialization

People
Owner: Nobody in particular
Requestors: spiceman [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 0.34
Fixed in: (no value)



Subject: PHP 5.3+ namespaces get wrong class when serialized
ie: my $data = unserialize(q|O:7:"Foo\\Bar":1:{s:5:"value";i:1;}|); # ref $data eq 'PHP::Serialization::Object::Foo\\Bar' $data = unserialize( serialize($data) ); # ref $data eq 'PHP::Serialiation::Object::Bar' test and patch attached.
Subject: 11namespaces.t
#!/usr/bin/env perl use Test::More tests => 1; use PHP::Serialization qw(unserialize serialize); my $encoded = q|O:7:"Foo\\Bar":1:{s:5:"value";i:1;}|; my $data = unserialize($encoded); is( ref $data, ref unserialize( serialize( $data )) );
Subject: Serialization.pm.diff
diff --git a/PHP/Serialization.pm b/PHP/Serialization.pm index 9dc3120..59a57c6 100644 --- a/PHP/Serialization.pm +++ b/PHP/Serialization.pm @@ -449,7 +449,8 @@ sub _encode { } elsif ( $type eq 'obj' ) { my $class = ref($val); - my $subclass = (split "::", $class)[-1]; + $class =~ /(\w+)$/; + my $subclass = $1; $buffer .= sprintf('O:%d:"%s":%d:', length($subclass), $subclass, scalar(keys %{$val})) . '{'; foreach ( %{$val} ) { $buffer .= $self->encode($_);
got the patch backwards, here's the correct one
Subject: Serialization.pm.diff
diff --git a/PHP/Serialization.pm b/PHP/Serialization.pm index 59a57c6..9dc3120 100644 --- a/PHP/Serialization.pm +++ b/PHP/Serialization.pm @@ -449,8 +449,7 @@ sub _encode { } elsif ( $type eq 'obj' ) { my $class = ref($val); - $class =~ /(\w+)$/; - my $subclass = $1; + my $subclass = (split "::", $class)[-1]; $buffer .= sprintf('O:%d:"%s":%d:', length($subclass), $subclass, scalar(keys %{$val})) . '{'; foreach ( %{$val} ) { $buffer .= $self->encode($_);
I found the github repo and made a pull request: https://github.com/bobtfish/perl-php-serialization/pull/2