Skip Menu |
 

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

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

People
Owner: Nobody in particular
Requestors: cowomally [...] nullium.net
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 4.37
Fixed in: (no value)



Subject: Problems when setting a param to undef with default serializer
Download (untitled) / with headers
text/plain 440b
I've encountered a problem when using $session->param('somevar', undef). When storing an object that holds another object, and restoring it later, I can no longer call methods on that 'inner' object. I've attached a testcase that shows this problem. When using Storable as serializer this problem does not appear. For the record, I have since found out about clear(), so no longer try to clear my parameters by setting them to undef ;-)
From: cowomally [...] nullium.net
Download (untitled) / with headers
text/plain 187b
On Mon Oct 27 05:04:57 2008, cowomally wrote: Show quoted text
> I've attached a testcase that shows this problem.
It appears my attachment did not make it? Another attempt. Apologies if it's now double.
#/usr/bin/perl -w package Container; sub new { my $class = shift; my $self = { items => [], }; bless ($self, $class); return $self; } sub add_item { my ($self,$item) = @_; push @{$self->{items}}, $item; return; } sub get_items { my $self = shift; return @{$self->{items}}; } package Item; sub new { my $class = shift; my $name = shift; my $self = { name => $name, }; bless ($self, $class); return $self; } sub get_name { my $self = shift; return $self->{name}; } package main; use strict; use Test::More tests => 21; use_ok('CGI::Session'); STORE:{ my $session = CGI::Session->new('serializer:default;id:static','testname',{Directory=>'.'}); ok($session); my $item1 = Item->new("test 123"); my $container = Container->new(); $container->add_item($item1); my ($item2) = $container->get_items(); is ($item1, $item2, 'Items are still equal after storing'); $session->param('container', $container); test_can($container,$item1,'Check in STORE of original item'); test_can($container,$item2,'Check in STORE of stored/retrieved item'); # If you remove the following line (and make sure there's not an already damaged session on disk), the problem is gone. $session->param('somevar', undef); $session->flush(); } LOAD:{ my $session = CGI::Session->load('serializer:default;id:static','testname',{Directory=>'.'}); my $container = $session->param('container'); my ($item) = $container->get_items(); test_can($container,$item, 'Check in LOAD after loading from session'); } sub test_can { my ($container, $item, $descr) = @_; warn "$descr\n"; can_ok('Container', 'add_item'); isa_ok($container, 'Container'); can_ok($container, 'add_item'); can_ok('Item', 'get_name'); isa_ok($item, 'Item'); can_ok($item, 'get_name'); }
Subject: Re: [rt.cpan.org #40405] Problems when setting a param to undef with default serializer
Date: Mon, 27 Oct 2008 09:14:29 -0500
To: bug-CGI-Session [...] rt.cpan.org
From: "Matt LeBlanc" <mleblanc [...] cpan.org>
Download (untitled) / with headers
text/plain 723b
This is my fault. The offending line in __walk contains the following: while (defined(my $x = shift @filter)) { which should be changed to while (@filter) { defined(my $x = shift @filter) or next; I have no access to the version control if someone would be so kind as to apply this change for me. Sorry about that. On Mon, Oct 27, 2008 at 4:10 AM, cowomally via RT < bug-CGI-Session@rt.cpan.org> wrote: Show quoted text
> Queue: CGI-Session > Ticket <URL: http://rt.cpan.org/Ticket/Display.html?id=40405 > > > On Mon Oct 27 05:04:57 2008, cowomally wrote:
> > I've attached a testcase that shows this problem.
> > It appears my attachment did not make it? Another attempt. Apologies if > it's now double. >
Download (untitled) / with headers
text/plain 222b
Patched in SVN. Thanx for the test file. That is /highly/ appreciated. And thanx for the fix! I'll look at various tickets over the weekend, and since I don't issue releases, I can't say when the fix(es) will hit CPAN.
Releasing tonight.


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.