Skip Menu |

This queue is for tickets about the CGI-Session CPAN distribution.

Report information
The Basics
Id: 20083
Status: resolved
Priority: 0/
Queue: CGI-Session

People
Owner: MARKSTOS [...] cpan.org
Requestors:
Cc:
AdminCc:

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



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');
From: Matt LeBlanc <mleblanc [...] cpan.org>
This isn't exactly the expected behavior of the default serializer since CGI::Session only expects the serializer to return a hashref or undef. The default serializer correctly handles the case where an object is was set through param. Regardless, I have committed a patch to SVN that should fix the root hashref as well so expect this to be fixed in the next release, whenever that may be.
Marking as resolved. Hopefully to be released soon.