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];
}