Skip Menu |

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

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

People
Owner: MARKSTOS [...] cpan.org
Requestors: andrew [...] an3e.org
duaneg [...] dghda.com
gspl3ster [...] gmail.com
pjs [...] cpan.org
Cc:
AdminCc:

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



Subject: Change of name from class to instance method breaks existing uses
The name method was changed from a class method to an instance method in 4.10, in response to RT#17979. However, as that enhancement request mentions, the old way of calling it as a class method still needs to be supported for backward compatibility. Maybe something like the attached patch would do the job?
Subject: name-method-class-or-instance.diff
--- CGI-Session-4.10/lib/CGI/Session.pm 2006-03-28 09:04:06.000000000 +0100 +++ CGI-Session-new/lib/CGI/Session.pm 2006-03-30 11:38:29.000000000 +0100 @@ -139,10 +139,28 @@ sub name { - unless ( defined $_[1] ) { - return $_[0]->{_NAME} || $CGI::Session::NAME; + my $self = shift; + + if ( ref $_[0] ) { + + # Instance method, new-style instance usage + if ( defined $_[1] ) { + $_[0]->{_NAME} = $_[1]; + } + else { + return $_[0]->{_NAME} || $CGI::Session::NAME; + } + } + else { + + # Class method, old-style global usage + if ( defined $_[1] ) { + $CGI::Session::NAME = $_[1]; + } + else { + return $CGI::Session::NAME; + } } - $_[0]->{_NAME} = $_[1]; }
CC: Matt LeBlanc <mleblanc [...] cpan.org>
Subject: Re: [rt.cpan.org #18451] Change of name from class to instance method breaks existing uses
Date: Thu, 30 Mar 2006 14:03:24 +0000
To: via RT <bug-CGI-Session [...] rt.cpan.org>
From: Mark Stosberg <mark [...] summersault.com>
On Thu, Mar 30, 2006 at 05:47:35AM -0500, via RT wrote: Show quoted text
> > The name method was changed from a class method to an instance method in > 4.10, in response to RT#17979. However, as that enhancement request > mentions, the old way of calling it as a class method still needs to be > supported for backward compatibility.
You are absolutely right. I'm sorry this slipped through. Show quoted text
> Maybe something like the attached patch would do the job?
We'll test it. Thanks for the contribution. ( Matt, Could you apply and check that we have tests for both calling styles? ) Thanks, Mark Show quoted text
> --- CGI-Session-4.10/lib/CGI/Session.pm 2006-03-28 09:04:06.000000000 +0100 > +++ CGI-Session-new/lib/CGI/Session.pm 2006-03-30 11:38:29.000000000 +0100 > @@ -139,10 +139,28 @@ > > > sub name { > - unless ( defined $_[1] ) { > - return $_[0]->{_NAME} || $CGI::Session::NAME; > + my $self = shift; > + > + if ( ref $_[0] ) { > + > + # Instance method, new-style instance usage > + if ( defined $_[1] ) { > + $_[0]->{_NAME} = $_[1]; > + } > + else { > + return $_[0]->{_NAME} || $CGI::Session::NAME; > + } > + } > + else { > + > + # Class method, old-style global usage > + if ( defined $_[1] ) { > + $CGI::Session::NAME = $_[1]; > + } > + else { > + return $CGI::Session::NAME; > + } > } > - $_[0]->{_NAME} = $_[1]; > } >
Subject: name() broken in 4.10
Documentation says that you can call CGI::Session->name("MY_SID"); but in fact this now results in Can't use string ("CGI::Session") as a HASH ref... This breaks the latest version of TWiki. Suggested patch: sub name { unless ( defined $_[1] ) { return $_[0]->{_NAME} || $CGI::Session::NAME; } - $_[0]->{_NAME} = $_[1]; + (ref $_[0] ? $_[0] : $CGI::Session::NAME) = $_[1]; }
Subject: Can't use string ("CGI::Session") as a HASH ref while "strict refs" in Session.pm line 145.
I just installed verion 4.10 (which is not listed in the "Broken in" box) to support TWiki-4.0.1. When I tried to fire up TWiki I get the following-- Can't use string ("CGI::Session") as a HASH ref while "strict refs" in use at /usr/lib/perl5/site_perl/5.8.6/CGI/Session.pm line 145. I did not have the same problem loading the same version of TWiki on another box, but with 4.09 of Session. Hope this is enough info. I'd be happy to investigate more if needed. Andrew Young
Subject: Re: [rt.cpan.org #18480] Can't use string ("CGI::Session") as a HASH ref while "strict refs" in Session.pm line 145.
Date: Fri, 31 Mar 2006 16:12:43 +0000
To: Guest via RT <bug-CGI-Session [...] rt.cpan.org>
From: Mark Stosberg <mark [...] summersault.com>
On Fri, Mar 31, 2006 at 11:02:55AM -0500, Guest via RT wrote: Show quoted text
> > Fri Mar 31 11:02:54 2006: Request 18480 was acted upon. > Transaction: Ticket created by guest > Queue: CGI-Session > Subject: Can't use string ("CGI::Session") as a HASH ref while "strict > refs" in Session.pm line 145. > Owner: Nobody > Requestors: andrew@an3e.org > Status: new > Ticket <URL: http://rt.cpan.org/Ticket/Display.html?id=18480 > > > > I just installed verion 4.10 (which is not listed in the "Broken in" > box) to support TWiki-4.0.1. When I tried to fire up TWiki I get the > following-- > > Can't use string ("CGI::Session") as a HASH ref while "strict refs" in > use at /usr/lib/perl5/site_perl/5.8.6/CGI/Session.pm line 145. > > I did not have the same problem loading the same version of TWiki on > another box, but with 4.09 of Session. > > Hope this is enough info. I'd be happy to investigate more if needed.
This is a known issue with 4.10. Bugs were filed by two users yesterday, including another Twiki user. Check the bug tracker for some patches users provided until an official release happens. Mark
From: sethg [...] ropine.com
On Fri Mar 31 11:02:54 2006, guest wrote: Show quoted text
> I just installed verion 4.10 (which is not listed in the "Broken in" > box) to support TWiki-4.0.1. When I tried to fire up TWiki I get the > following-- > > Can't use string ("CGI::Session") as a HASH ref while "strict refs" in > use at /usr/lib/perl5/site_perl/5.8.6/CGI/Session.pm line 145.
I just tried to do exactly the same thing and got exactly the same error. Running perl -MCGI::Session -e 'CGI::Session->name("test"); 1;' from the command line gives the same error message. This is on a virtual Linux server (at openhosting.com) running Fedora Core 4. Putting 'no strict "refs";' on the line after "use strict;" lets me see the view page, although I have no idea if it's introduced other problems, and it's probably not the best long-term solution.
From: sethg [...] ropine.com
I composed my reply while you were posting yours. Sorry...
Subject: CGI-Session-4.10
My browser reported : "Software error: Can't use string ("CGI::Session") as a HASH ref while "strict refs" in use at /usr/local/share/perl/5.8.7/CGI/Session.pm line 145." OS -> Knoppix4.0 (debian) Perl 5.8.7 While installing twiki 4.0 Please help. I will be grateful DKMuthiah
Subject: Re: [rt.cpan.org #18488] CGI-Session-4.10
Date: Fri, 31 Mar 2006 20:30:55 -0500
To: Guest via RT <bug-CGI-Session [...] rt.cpan.org>
From: Mark Stosberg <mark [...] summersault.com>
On Fri, Mar 31, 2006 at 07:59:04PM -0500, Guest via RT wrote: Show quoted text
> > Fri Mar 31 19:58:57 2006: Request 18488 was acted upon. > Transaction: Ticket created by guest > Queue: CGI-Session > Subject: CGI-Session-4.10 > Owner: Nobody > Requestors: gspl3ster@gmail.com > Status: new > Ticket <URL: http://rt.cpan.org/Ticket/Display.html?id=18488 > > > > My browser reported : > "Software error: > Can't use string ("CGI::Session") as a HASH ref while "strict refs" in > use at /usr/local/share/perl/5.8.7/CGI/Session.pm line 145." > > OS -> Knoppix4.0 (debian) > Perl 5.8.7 > While installing twiki 4.0
This issue has already been reported and is being worked on. Please check the bug tracker to find the previous reports, including submitted patches! Installing the previous version should avoid the issue, too. Mark
From: naveen.bidhuri [...] gmail.com
I am getting the same error while running Twiki. Could you please tell me which patches can resolve this issue I cannot find the details of it anywhere. Thanks in advance. -Naveen On Fri Mar 31 11:40:21 2006, guest wrote: Show quoted text
> I composed my reply while you were posting yours. Sorry...
CC: Sherzod Ruzmetov <sherzodr [...] cpan.org>
Subject: Re: [rt.cpan.org #18480] release trouble with CGI::Session 4.11 to address name() regression
Date: Tue, 4 Apr 2006 10:53:52 -0400
To: Guest via RT <bug-CGI-Session [...] rt.cpan.org>
From: Mark Stosberg <mark [...] summersault.com>
On Mon, Apr 03, 2006 at 08:03:31PM -0400, Guest via RT wrote: Show quoted text
> > Queue: CGI-Session > Ticket <URL: http://rt.cpan.org/Ticket/Display.html?id=18480 > > > I am getting the same error while running Twiki. Could you please tell > me which patches can resolve this issue I cannot find the details of > it anywhere.
A new release to address it is, unofficially here: http://mark.stosberg.com/perl/CGI-Session-4.11.tar.gz However, I'm having technical difficulties trying to release it to CPAN. (I've tried twice already!). I'm CC'ing my co-maintainer, who may have better luck with an official release. Mark
CC: undisclosed-recipients: ;
Subject: Re: [rt.cpan.org #18480] release trouble with CGI::Session 4.11 to address name() regression
Date: Tue, 4 Apr 2006 14:03:29 -0400
To: "mark [...] summersault.com via RT" <bug-CGI-Session [...] rt.cpan.org>
From: Mark Stosberg <mark [...] summersault.com>
On Tue, Apr 04, 2006 at 10:54:39AM -0400, mark@summersault.com via RT wrote: Show quoted text
> > Queue: CGI-Session > Ticket <URL: http://rt.cpan.org/Ticket/Display.html?id=18480 > > > On Mon, Apr 03, 2006 at 08:03:31PM -0400, Guest via RT wrote:
> > > > Queue: CGI-Session > > Ticket <URL: http://rt.cpan.org/Ticket/Display.html?id=18480 > > > > > I am getting the same error while running Twiki. Could you please tell > > me which patches can resolve this issue I cannot find the details of > > it anywhere.
> > A new release to address it is, unofficially here: > http://mark.stosberg.com/perl/CGI-Session-4.11.tar.gz > > However, I'm having technical difficulties trying to release it to CPAN. > (I've tried twice already!). > > I'm CC'ing my co-maintainer, who may have better luck with an official > release.
I see the 4.11 releas on CPAN now, so apparently it did get through. Mark
Should be fixed in 4.13. Mark