Subject: | CGI::Session::Serialize::default seems to break class inheritance hierarchy |
I wrote a session data with 'default' serializer.
The session data was a instance of ModuleB.
ModuleB was a inheritance of ModuleA.
Retrieved session data object was a instance of ModuleB.(OK)
But the object didn't support ModuleA methods.(NG)
Example script attached.
In this script, the message '$o is a ModuleA' should be printed, but isn't.
With other serializers ('storable', 'yaml', etc), the message is
successfully printed.
--
Perl version 5.8.8
Subject: | broken_inheritance.pl |
#!/usr/bin/perl
package ModuleA;
use base qw/Class::Accessor::Fast/;
__PACKAGE__->mk_accessors(qw/field1/);
package ModuleB;
use base qw/ModuleA/;
package main;
use UNIVERSAL::require;
my $serializer = 'CGI::Session::Serialize::default';
$serializer->use;
my $b = ModuleB->new;
print "\$b is a ModuleB\n"
if $b->isa('ModuleB');
print "\$b is a ModuleA\n"
if $b->isa('ModuleA');
my $session = $serializer->freeze($b);
my $o = $serializer->thaw($session);
print "\$o is a ModuleB\n"
if $o->isa('ModuleB');
print "\$o is a ModuleA\n"
if $o->isa('ModuleA');