From 40c073e65e63f82e6dc93a5925635dee5cf35df7 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Fri, 12 Nov 2010 11:37:02 -0800 Subject: [PATCH 01/16] Document the closed method for Session. --- lib/WebGUI/Session.pm | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/WebGUI/Session.pm b/lib/WebGUI/Session.pm index 51a11932f..d0f9e418e 100644 --- a/lib/WebGUI/Session.pm +++ b/lib/WebGUI/Session.pm @@ -188,6 +188,14 @@ sub close { $self->{closed} = 1; } +#------------------------------------------------------------------- + +=head2 closed + +Returns true if this session has been closed. + +=cut + sub closed { my $self = shift; return $self->{closed}; From 468ad16246e194600b2c1b8c1d022614f5fca69f Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Mon, 15 Nov 2010 09:06:45 -0800 Subject: [PATCH 02/16] Merge Session::Var into Session. var is left as a stub for backwards compatibility. --- lib/WebGUI/Session.pm | 205 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 189 insertions(+), 16 deletions(-) diff --git a/lib/WebGUI/Session.pm b/lib/WebGUI/Session.pm index d0f9e418e..b0917e133 100644 --- a/lib/WebGUI/Session.pm +++ b/lib/WebGUI/Session.pm @@ -80,8 +80,7 @@ B It is important to distinguish the difference between a WebGUI session $session->style $session->url $session->user - $session->var - + =head1 METHODS @@ -143,7 +142,7 @@ sub cache { } $config->{namespace} ||= $self->config->get('sitename')->[0]; }; - + $resolveConf->( $cacheConf ); if ( $cacheConf->{l1_cache} ) { $resolveConf->( $cacheConf->{l1_cache} ); @@ -278,7 +277,7 @@ Returns a random slave database handler, if one is defined, otherwise it returns sub dbSlave { my $self = shift; - return $self->db if $self->var->isAdminOn; + return $self->db if $self->isAdminOn; unless (exists $self->{_slave}) { my @slaves = (); foreach (1..3) { @@ -333,6 +332,23 @@ sub duplicate { } +#------------------------------------------------------------------- + +=head2 end ( ) + +Removes the specified session from memory and database. + +=cut + +sub end { + my $self = shift; + my $id = $self->getId; + $session->cache->remove($id); + $session->scratch->deleteAll; + $session->db->write("delete from userSession where sessionId=?",[$id]); + delete $session->{_user}; +} + #------------------------------------------------------------------- =head2 errorHandler ( ) @@ -364,6 +380,48 @@ sub form { #------------------------------------------------------------------- +=head2 get ( varName ) + +Retrieves the current value of a session variable. + +=head3 varName + +The name of the variable. + +=head4 lastIP + +The last IP address the user came from. + +=head4 lastPageView + +The epoch date of the last interaction with the session. + +=head4 userId + +The unique id of the user this session currently bound to. + +=head4 adminOn + +A boolean indicating whether this session has admin mode enabled or not. + +=head4 sessionId + +The sessionId associated with this session. + +=head4 expires + +The epoch date when this user session will expire if it's not accessed again by then. + +=cut + +sub get { + my $self = shift; + my $varName = shift; + return $self->{_var}{$varName}; +} + +#------------------------------------------------------------------- + =head2 getId ( ) Returns the current session Id. @@ -439,6 +497,19 @@ sub id { } +#------------------------------------------------------------------- + +=head2 isAdminOn ( ) + +Returns a boolean indicating whether admin mode is on or not. + +=cut + +sub isAdminOn { + my $self = shift; + return $self->get("adminOn"); +} + #------------------------------------------------------------------- =head2 log ( ) @@ -497,17 +568,49 @@ sub open { my $request = WebGUI::Session::Request->new($env); $self->{_request} = $request; $self->{_response} = $request->new_response( 200 ); - + # Use the WebGUI::Session::Request object to look up the sessionId from cookies, if it # wasn't given explicitly $sessionId ||= $request->cookies->{$config->getCookieName}; - + # If the sessionId is still unset or is invalid, generate a new one if (!$sessionId || !$self->id->valid($sessionId)) { $sessionId = $self->id->generate; } - - $self->{_var} = WebGUI::Session::Var->new($self,$sessionId, $noFuss); + $self->{_var} = $session->cache->get($sessionId); + unless ($self->{_var}{sessionId} eq $sessionId) { + $self->{_var} = $session->db->quickHashRef("select * from userSession where sessionId=?", [$sessionId]); + } + ##We have to make sure that the session variable has a sessionId, otherwise downstream users of + ##the object will break + if ($noFuss && $self->{_var}{sessionId}) { + $self->{_sessionId} = $self->{_var}{sessionId}; + return $self; + } + if ($self->{_var}{expires} && $self->{_var}{expires} < time()) { ##Session expired, start a new one with the same Id, as visitor + $self->end; + $self->start(1, $sessionId); + } + elsif ($self->{_var}{sessionId} ne "") { ##Fetched an existing session. Update variables with recent data. + my $time = time(); + my $timeout = $self->setting->get("sessionTimeout"); + $self->{_var}{lastPageView} = $time; + $self->{_var}{lastIP} = $self->request->address; + $self->{_var}{expires} = $time + $timeout; + if ($self->{_var}{nextCacheFlush} > 0 && $self->{_var}{nextCacheFlush} < $time) { + delete $self->{_var}{nextCacheFlush}; + $self->db->setRow("userSession","sessionId",$self->{_var}); + } + else { + $self->{_var}{nextCacheFlush} = $time + $self->config->get("hotSessionFlushToDb"); + $self->cache->set($sessionId, $self->{_var}, $timeout); + } + } + else { ##Start a new default session with the requested, non-existant id. + $self->start(1,$sessionId); + } + +# $self->{_var} = WebGUI::Session::Var->new($self,$sessionId, $noFuss); return $self; } @@ -638,6 +741,45 @@ sub setting { } +#------------------------------------------------------------------- + +=head2 start ( [ userId, sessionId ] ) + +Start a new user session. Returns the user session id. The session variable's sessionId +is set to the var object's session id. Also sets the user's CSRF token. + +=head3 userId + +The user id of the user to create a session for. Defaults to 1 (Visitor). + +=head3 sessionId + +Session id will be generated if not specified. In almost every case you should let the system generate the session id. + +=cut + +sub start { + my $self = shift; + my $userId = shift; + $userId = 1 if ($userId eq ""); + my $sessionId = shift; + $sessionId = $self->id->generate if ($sessionId eq ""); + my $timeout = $self->setting->get('sessionTimeout'); + my $time = time(); + $self->{_var} = { + expires => $time + $timeout, + lastPageView => $time, + lastIP => $self->request->address, + adminOn => 0, + userId => $userId + }; + $self->{_sessionId} = $sessionId; + $self->cache->set($sessionId, $self->{_var}, $timeout); + delete $self->{_var}{nextCacheFlush}; + $self->db->setRow("userSession","sessionId",$self->{_var}, $sessionId); + $self->scratch->set('webguiCsrfToken', $self->id->generate); # create cross site request forgery token +} + #------------------------------------------------------------------- =head2 stow ( ) @@ -671,6 +813,38 @@ sub style { } +#------------------------------------------------------------------- + +=head2 switchAdminOff ( ) + +Disables admin mode. + +=cut + +sub switchAdminOff { + my $self = shift; + $self->{_var}{adminOn} = 0; + $session->cache->set($self->getId, $self->{_var}, $session->setting->get('sessionTimeout')); + delete $self->{_var}{nextCacheFlush}; + $session->db->setRow("userSession","sessionId", $self->{_var}); +} + +#------------------------------------------------------------------- + +=head2 switchAdminOn ( ) + +Enables admin mode. + +=cut + +sub switchAdminOn { + my $self = shift; + $self->{_var}{adminOn} = 1; + $session->cache->set($self->getId, $self->{_var}, $session->setting->get('sessionTimeout')); + delete $self->{_var}{nextCacheFlush}; + $self->session->db->setRow("userSession","sessionId", $self->{_var}); +} + #------------------------------------------------------------------- =head2 url ( ) @@ -712,15 +886,16 @@ sub user { my $option = shift; if (defined $option) { my $userId = $option->{userId} || $option->{user}->userId; - $self->var->start($userId,$self->getId); + $self->start($userId,$self->getId); if ($self->setting->get("passiveProfilingEnabled")) { $self->db->write("update passiveProfileLog set userId = ? where sessionId = ?",[$userId,$self->getId]); } delete $self->{_stow}; $self->{_user} = $option->{user} || WebGUI::User->new($self, $userId); $self->request->env->{REMOTE_USER} = $self->{_user}->username if $self->request; - } elsif (!exists $self->{_user}) { - $self->{_user} = WebGUI::User->new($self, $self->var->get('userId')); + } + elsif (!exists $self->{_user}) { + $self->{_user} = WebGUI::User->new($self, $self->get('userId')); $self->request->env->{REMOTE_USER} = $self->{_user}->username if $self->request; } return $self->{_user}; @@ -731,16 +906,14 @@ sub user { =head2 var ( ) +DEPRECATED. Session::Var was absorbed into Session in WebGUI 8.0. + Returns a reference to the WebGUI::Session::Var object. =cut sub var { - my $self = shift; - unless ($self->{_var}) { - $self->{_var} = WebGUI::Session::Var->new($self); - } - return $self->{_var}; + return $_->[0]; } 1; From 4d544330cdb0b23b7448638c0d58d2a47887a94d Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Mon, 15 Nov 2010 09:08:39 -0800 Subject: [PATCH 03/16] Remove _var from the set of hash keys being cleaned up in the Session. --- lib/WebGUI/Session.pm | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/WebGUI/Session.pm b/lib/WebGUI/Session.pm index b0917e133..8465e80b4 100644 --- a/lib/WebGUI/Session.pm +++ b/lib/WebGUI/Session.pm @@ -181,7 +181,7 @@ sub close { # Kill circular references. The literal list is so that the order # can be explicitly shuffled as necessary. - foreach my $key (qw/_asset _datetime _icon _slave _db _form _http _id _output _privilege _scratch _setting _stow _style _url _user _var _cache _log _response _request/) { + foreach my $key (qw/_asset _datetime _icon _slave _db _form _http _id _output _privilege _scratch _setting _stow _style _url _user _cache _log _response _request/) { delete $self->{$key}; } $self->{closed} = 1; @@ -610,7 +610,6 @@ sub open { $self->start(1,$sessionId); } -# $self->{_var} = WebGUI::Session::Var->new($self,$sessionId, $noFuss); return $self; } From c4365bf2b75ab703000dd6ea334356e7efabaabd Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Mon, 15 Nov 2010 09:22:43 -0800 Subject: [PATCH 04/16] session->self cleanup --- lib/WebGUI/Session.pm | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/WebGUI/Session.pm b/lib/WebGUI/Session.pm index 8465e80b4..7f856cd38 100644 --- a/lib/WebGUI/Session.pm +++ b/lib/WebGUI/Session.pm @@ -343,10 +343,10 @@ Removes the specified session from memory and database. sub end { my $self = shift; my $id = $self->getId; - $session->cache->remove($id); - $session->scratch->deleteAll; - $session->db->write("delete from userSession where sessionId=?",[$id]); - delete $session->{_user}; + $self->cache->remove($id); + $self->scratch->deleteAll; + $self->db->write("delete from userSession where sessionId=?",[$id]); + delete $self->{_user}; } #------------------------------------------------------------------- @@ -577,9 +577,9 @@ sub open { if (!$sessionId || !$self->id->valid($sessionId)) { $sessionId = $self->id->generate; } - $self->{_var} = $session->cache->get($sessionId); + $self->{_var} = $self->cache->get($sessionId); unless ($self->{_var}{sessionId} eq $sessionId) { - $self->{_var} = $session->db->quickHashRef("select * from userSession where sessionId=?", [$sessionId]); + $self->{_var} = $self->db->quickHashRef("select * from userSession where sessionId=?", [$sessionId]); } ##We have to make sure that the session variable has a sessionId, otherwise downstream users of ##the object will break @@ -823,9 +823,9 @@ Disables admin mode. sub switchAdminOff { my $self = shift; $self->{_var}{adminOn} = 0; - $session->cache->set($self->getId, $self->{_var}, $session->setting->get('sessionTimeout')); + $self->cache->set($self->getId, $self->{_var}, $self->setting->get('sessionTimeout')); delete $self->{_var}{nextCacheFlush}; - $session->db->setRow("userSession","sessionId", $self->{_var}); + $self->db->setRow("userSession","sessionId", $self->{_var}); } #------------------------------------------------------------------- @@ -839,9 +839,9 @@ Enables admin mode. sub switchAdminOn { my $self = shift; $self->{_var}{adminOn} = 1; - $session->cache->set($self->getId, $self->{_var}, $session->setting->get('sessionTimeout')); + $self->cache->set($self->getId, $self->{_var}, $self->setting->get('sessionTimeout')); delete $self->{_var}{nextCacheFlush}; - $self->session->db->setRow("userSession","sessionId", $self->{_var}); + $self->db->setRow("userSession","sessionId", $self->{_var}); } #------------------------------------------------------------------- From 7f5a992cfdc9845fedeecf68ca75c8f2d6d2b03b Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Mon, 15 Nov 2010 09:22:51 -0800 Subject: [PATCH 05/16] Update WebGUI::Test for new Session --- lib/WebGUI/Test.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/WebGUI/Test.pm b/lib/WebGUI/Test.pm index ee1308a0e..b677cc765 100644 --- a/lib/WebGUI/Test.pm +++ b/lib/WebGUI/Test.pm @@ -716,7 +716,7 @@ Example call: }, 'WebGUI::Session' => sub { my $session = shift; - $session->var->end; + $session->end; $session->close; }, 'WebGUI::LDAPLink' => sub { @@ -832,7 +832,7 @@ sub cleanup { while @guarded; if ( our $SESSION ) { - $SESSION->var->end; + $SESSION->end; $SESSION->close; undef $SESSION; } From aeb825a14f4bb2119fad3ceeb70bba2f5d72e0ec Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Mon, 15 Nov 2010 10:10:05 -0800 Subject: [PATCH 06/16] Switch sense of test answer and question to the correct order. --- t/Session.t | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/t/Session.t b/t/Session.t index 03a4702a8..a329a5f12 100644 --- a/t/Session.t +++ b/t/Session.t @@ -37,7 +37,7 @@ is($session->user->profileField('uiLevel'), 9, 'Set session user to Admin, check my $dupe = $session->duplicate; WebGUI::Test->addToCleanup($dupe); -is $session->getId, $dupe->getId, 'duplicated session has the same sessionId'; +is $dupe->getId, $session->getId, 'duplicated session has the same sessionId'; ################################################################ # From cb6ea771dcaabc6f7b6bcdeb7b522955d0c57da5 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Mon, 15 Nov 2010 10:10:23 -0800 Subject: [PATCH 07/16] Set the internal session id in all cases. We should consider not storing it twice... --- lib/WebGUI/Session.pm | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/WebGUI/Session.pm b/lib/WebGUI/Session.pm index 7f856cd38..e714a1138 100644 --- a/lib/WebGUI/Session.pm +++ b/lib/WebGUI/Session.pm @@ -594,6 +594,7 @@ sub open { elsif ($self->{_var}{sessionId} ne "") { ##Fetched an existing session. Update variables with recent data. my $time = time(); my $timeout = $self->setting->get("sessionTimeout"); + $self->{_sessionId} = $self->{_var}{sessionId}; $self->{_var}{lastPageView} = $time; $self->{_var}{lastIP} = $self->request->address; $self->{_var}{expires} = $time + $timeout; From 64fc48a5f449aeee1505e69e4514f919bfcff541 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Mon, 15 Nov 2010 11:02:32 -0800 Subject: [PATCH 08/16] Indenting/white space. --- lib/WebGUI/Session.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/WebGUI/Session.pm b/lib/WebGUI/Session.pm index e714a1138..8f7048453 100644 --- a/lib/WebGUI/Session.pm +++ b/lib/WebGUI/Session.pm @@ -761,7 +761,7 @@ Session id will be generated if not specified. In almost every case you should l sub start { my $self = shift; my $userId = shift; - $userId = 1 if ($userId eq ""); + $userId = 1 if ($userId eq ""); my $sessionId = shift; $sessionId = $self->id->generate if ($sessionId eq ""); my $timeout = $self->setting->get('sessionTimeout'); From 3a601c2c96a0d281afb170510aac56d6e244cdec Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Mon, 15 Nov 2010 11:02:41 -0800 Subject: [PATCH 09/16] Begin moving Var tests over to Session. --- t/Session.t | 39 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/t/Session.t b/t/Session.t index a329a5f12..ad4898865 100644 --- a/t/Session.t +++ b/t/Session.t @@ -17,8 +17,6 @@ use WebGUI::User; use Test::More; -plan tests => 5; # increment this value for each test you create - my $session = WebGUI::Test->session; my $user = WebGUI::User->new($session, "new"); @@ -37,6 +35,8 @@ is($session->user->profileField('uiLevel'), 9, 'Set session user to Admin, check my $dupe = $session->duplicate; WebGUI::Test->addToCleanup($dupe); +is($session->get('sessionId'), $session->getId, 'getId returns sessionId'); + is $dupe->getId, $session->getId, 'duplicated session has the same sessionId'; ################################################################ @@ -59,4 +59,39 @@ WebGUI::Test->addToCleanup(sub {$session->config->delete('dbslave2');}); my $slave2 = $session->dbSlave; isa_ok($slave2, 'WebGUI::SQL::db'); +cmp_ok($session->get("lastPageView"), '>', 0, "lastPageView set to something"); + +can_ok($session, qw/isAdminOn switchAdminOn switchAdminOff/); +is($session->isAdminOn, 0, "isAdminOn()"); +$session->switchAdminOn; +is($session->isAdminOn, 1, "switchAdminOn()"); +$session->switchAdminOff; +is($session->isAdminOn, 0, "switchAdminOff()"); + +my $token = $session->scratch->get('webguiCsrfToken'); +ok( $token, 'CSRF token set'); +ok( $session->id->valid($token), '...is a valid GUID'); + +my $id = $session->getId; +my ($count) = $session->db->quickArray("select count(*) from userSession where sessionId=?", [$id]); +is($count, 1, "created an user session entry in the database"); + +my $varSession = WebGUI::Session->open($session->config); +WebGUI::Test->addToCleanup($varSession); +my $varTime = time(); +isnt($varSession->scratch->get('webguiCsrfToken'), $token, '... calling new without sessionId creates a new token'); +isnt($varSession->getId, $session->getId, "new session has a different id from current session"); + +my $varExpires = $varTime + $session->setting->get('sessionTimeout'); +cmp_ok(abs($varSession->get('lastPageView') - $varTime), '<=', 1, 'lastPageView set correctly'); +cmp_ok(abs($varSession->get('expires') - $varExpires), '<=', 1, 'expires set correctly'); + +is($varSession->get('userId'), 1, 'default userId is 1'); + +is($varSession->get('adminOn'), $varSession->isAdminOn, "get('adminOn') and isAdminOn return the same thing"); +is($varSession->get('adminOn'), 0, "adminOn is off by default"); ##retest +is($varSession->get('lastIP'), '192.168.0.34', "lastIP fetched"); + +done_testing; + #vim:ft=perl From 999cbf70f34df9b571b1c84274fce630f9a30fdd Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Mon, 15 Nov 2010 18:56:05 -0800 Subject: [PATCH 10/16] Update Upgrade packages so they'll work varless. --- lib/WebGUI/Upgrade/File/wgpkg.pm | 2 +- lib/WebGUI/Upgrade/Script.pm | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/WebGUI/Upgrade/File/wgpkg.pm b/lib/WebGUI/Upgrade/File/wgpkg.pm index 57a73754e..60fe70c66 100644 --- a/lib/WebGUI/Upgrade/File/wgpkg.pm +++ b/lib/WebGUI/Upgrade/File/wgpkg.pm @@ -46,7 +46,7 @@ sub run { } $versionTag->commit; - $session->var->end; + $session->end; $session->close; return $package; diff --git a/lib/WebGUI/Upgrade/Script.pm b/lib/WebGUI/Upgrade/Script.pm index 19810e71c..d46bf14de 100644 --- a/lib/WebGUI/Upgrade/Script.pm +++ b/lib/WebGUI/Upgrade/Script.pm @@ -113,7 +113,7 @@ sub _build_exports { if (WebGUI::VersionTag->getWorking($session, 'nocreate')) { $version_tag_sub->()->commit; } - $session->var->end; + $session->end; $session->close; } undef $session; From e319f56a04b0750a5931c05b0894b9581fafd448 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Mon, 15 Nov 2010 18:56:21 -0800 Subject: [PATCH 11/16] Pull more test over from Var. --- t/Session.t | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/t/Session.t b/t/Session.t index ad4898865..822cabe32 100644 --- a/t/Session.t +++ b/t/Session.t @@ -30,7 +30,7 @@ is($userId, $user->userId, 'changing session user changes sessionId inside userS $session->user({userId => 3}); is($session->user->userId, 3, 'Set session user to Admin, check userId==3'); -is($session->user->profileField('uiLevel'), 9, 'Set session user to Admin, check uiLevel==9'); +is($session->user->get('uiLevel'), 9, 'Set session user to Admin, check uiLevel==9'); my $dupe = $session->duplicate; WebGUI::Test->addToCleanup($dupe); @@ -92,6 +92,19 @@ is($varSession->get('adminOn'), $varSession->isAdminOn, "get('adminOn') and isAd is($varSession->get('adminOn'), 0, "adminOn is off by default"); ##retest is($varSession->get('lastIP'), '192.168.0.34', "lastIP fetched"); + +my $var2 = WebGUI::Session->open($session->config, undef, 'illegalSessionIdThatIsTooLong'); +# '1234567890123456789012' +isa_ok($var2, 'WebGUI::Session', 'invalid sessionId will still produce a Session object'); +($count) = $session->db->quickArray("select count(*) from userSession where sessionId=?",[$var2->getId]); +is($count, 0, "object store of sessionId does not match database record"); +my $var2Id = $var2->getId; +$var2->end; +my $idToDelete = substr $var2Id,0,22; +($count) = $session->db->quickArray("select count(*) from userSession where sessionId=?",[$idToDelete]); +is($count, 1, "Unable to delete database record for Var object with invalid sessionId"); + + done_testing; #vim:ft=perl From 39dc7323f318674d26479717d671f9a6112dea2a Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Wed, 17 Nov 2010 16:18:51 -0800 Subject: [PATCH 12/16] Finish moving over Var tests into session. Remove Session::Var. --- lib/WebGUI/Session.pm | 8 +- lib/WebGUI/Session/Var.pm | 297 -------------------------------------- t/Session.t | 130 +++++++++++++++-- t/Session/Var.t | 216 --------------------------- 4 files changed, 124 insertions(+), 527 deletions(-) delete mode 100644 lib/WebGUI/Session/Var.pm delete mode 100644 t/Session/Var.t diff --git a/lib/WebGUI/Session.pm b/lib/WebGUI/Session.pm index 8f7048453..65bff7eeb 100644 --- a/lib/WebGUI/Session.pm +++ b/lib/WebGUI/Session.pm @@ -19,7 +19,6 @@ use 5.010; use CHI; use File::Temp qw( tempdir ); -use Scalar::Util qw( weaken ); use HTTP::Message::PSGI; use HTTP::Request::Common; use WebGUI::Config; @@ -417,7 +416,10 @@ The epoch date when this user session will expire if it's not accessed again by sub get { my $self = shift; my $varName = shift; - return $self->{_var}{$varName}; + if ($varName) { + return $self->{_var}{$varName}; + } + return $self->{_var}; } #------------------------------------------------------------------- @@ -547,7 +549,7 @@ If you have a L env hash, you might find the sessionId at: $env->{'psgix.s =head3 noFuss -Uses simple session vars. See WebGUI::Session::Var::new() for more details. +Uses simple session vars. See WebGUI::Session->open() for more details. =cut diff --git a/lib/WebGUI/Session/Var.pm b/lib/WebGUI/Session/Var.pm deleted file mode 100644 index 6f611b1c0..000000000 --- a/lib/WebGUI/Session/Var.pm +++ /dev/null @@ -1,297 +0,0 @@ -package WebGUI::Session::Var; - -=head1 LEGAL - - ------------------------------------------------------------------- - WebGUI is Copyright 2001-2009 Plain Black Corporation. - ------------------------------------------------------------------- - Please read the legal notices (docs/legal.txt) and the license - (docs/license.txt) that came with this distribution before using - this software. - ------------------------------------------------------------------- - http://www.plainblack.com info@plainblack.com - ------------------------------------------------------------------- - -=cut - -use strict; -use Scalar::Util qw(weaken); - -=head1 NAME - -Package WebGUI::Session::Var - -=head1 DESCRIPTION - -This package is the persistence layer for WebGUI session variables. - -=head1 SYNOPSIS - -$var = WebGUI::Session::Var->new($session); - -$value = $var->get('lastIP'); - -$var->start; -$var->end; - -$boolean = $var->isAdminOn; - -$var->switchAdminOff; -$var->switchAdminOn; - - -=head1 METHODS - -These methods are available from this package: - -=cut - - -#------------------------------------------------------------------- - -=head2 end ( ) - -Removes the specified user session from memory and database. - -=cut - -sub end { - my $self = shift; - my $session = $self->session; - my $id = $self->getId; - $session->cache->remove($id); - $session->scratch->deleteAll; - $session->db->write("delete from userSession where sessionId=?",[$id]); - delete $session->{_user}; -} - -#------------------------------------------------------------------- - -=head2 get ( varName ) - -Retrieves the current value of a session variable. - -=head3 varName - -The name of the variable. - -=head4 lastIP - -The last IP address the user came from. - -=head4 lastPageView - -The epoch date of the last interaction with the session. - -=head4 userId - -The unique id of the user this session currently bound to. - -=head4 adminOn - -A boolean indicating whether this session has admin mode enabled or not. - -=head4 sessionId - -The sessionId associated with this session. - -=head4 expires - -The epoch date when this user session will expire if it's not accessed again by then. - -=cut - -sub get { - my $self = shift; - my $var = shift; - return $self->{_var}{$var}; -} - -#------------------------------------------------------------------- - -=head2 getId ( ) - -Returns the ID of the current session. - -=cut - -sub getId { - my $self = shift; - $self->get("sessionId"); -} - - -#------------------------------------------------------------------- - -=head2 isAdminOn ( ) - -Returns a boolean indicating whether admin mode is on or not. - -=cut - -sub isAdminOn { - my $self = shift; - return $self->get("adminOn"); -} - -#------------------------------------------------------------------- - -=head2 new ( session, sessionId, noFuss ) - -Constructor. Overwrites the sessionId of $session with its own id. Returns a var object. - -=head3 session - -A reference to the session. - -=head3 sessionId - -The specific sessionId you want to instantiate. - -=head3 noFuss - -A boolean, that if true will not update the session, or check if it's -expired. This is mainly for WebGUI session maintenance, and shouldn't -normally be used by anyone. - -=cut - -sub new { - my ($class, $session, $sessionId, $noFuss) = @_; - my $self = bless { _session => $session }, $class; - weaken $self->{_session}; - if ($sessionId eq "") { ##New session - $self->start(1); - } - else { ##existing session requested - $self->{_var} = $session->cache->get($sessionId); - unless ($self->{_var}{sessionId} eq $sessionId) { - $self->{_var} = $session->db->quickHashRef("select * from userSession where sessionId=?",[$sessionId]); - } - ##We have to make sure that the session variable has a sessionId, otherwise downstream users of - ##the object will break - if ($noFuss && $self->{_var}{sessionId}) { - $self->session->{_sessionId} = $self->{_var}{sessionId}; - return $self; - } - if ($self->{_var}{expires} && $self->{_var}{expires} < time()) { ##Session expired, start a new one with the same Id - $self->end; - $self->start(1,$sessionId); - } - elsif ($self->{_var}{sessionId} ne "") { ##Fetched an existing session. Update variables with recent data. - my $time = time(); - my $timeout = $session->setting->get("sessionTimeout"); - $self->{_var}{lastPageView} = $time; - $self->{_var}{lastIP} = $session->request->address; - $self->{_var}{expires} = $time + $timeout; - if ($self->{_var}{nextCacheFlush} > 0 && $self->{_var}{nextCacheFlush} < $time) { - delete $self->{_var}{nextCacheFlush}; - $session->db->setRow("userSession","sessionId",$self->{_var}); - } - else { - $self->{_var}{nextCacheFlush} = $time + $session->config->get("hotSessionFlushToDb"); - $session->cache->set($sessionId, $self->{_var}, $timeout); - } - $self->session->{_sessionId} = $self->{_var}{sessionId}; - return $self; - } - else { ##Start a new default session with the requested, non-existant id. - $self->start(1,$sessionId); - } - } - return $self; -} - - -#------------------------------------------------------------------- - -=head2 session ( ) - -Returns a reference to the session object. - -=cut - -sub session { - my $self = shift; - return $self->{_session}; -} - - -#------------------------------------------------------------------- - -=head2 start ( [ userId, sessionId ] ) - -Start a new user session. Returns the user session id. The session variable's sessionId -is set to the var object's session id. Also sets the user's CSRF token. - -=head3 userId - -The user id of the user to create a session for. Defaults to 1 (Visitor). - -=head3 sessionId - -Session id will be generated if not specified. In almost every case you should let the system generate the session id. - -=cut - -sub start { - my $self = shift; - my $userId = shift; - $userId = 1 if ($userId eq ""); - my $sessionId = shift; - my $session = $self->session; - my $id = $session->id; - $sessionId = $id->generate if ($sessionId eq ""); - my $timeout = $session->setting->get('sessionTimeout'); - my $time = time(); - $self->{_var} = { - expires => $time + $timeout, - lastPageView => $time, - lastIP => $session->request->address, - adminOn => 0, - userId => $userId - }; - $self->session->{_sessionId} = $sessionId; - $session->cache->set($sessionId, $self->{_var}, $timeout); - delete $self->{_var}{nextCacheFlush}; - $session->db->setRow("userSession","sessionId",$self->{_var},$sessionId); - $self->{_sessionId} = $sessionId; - $session->scratch->set('webguiCsrfToken', $id->generate); # create cross site request forgery token -} - -#------------------------------------------------------------------- - -=head2 switchAdminOff ( ) - -Disables admin mode. - -=cut - -sub switchAdminOff { - my $self = shift; - $self->{_var}{adminOn} = 0; - my $session = $self->session; - $session->cache->set($self->getId, $self->{_var}, $session->setting->get('sessionTimeout')); - delete $self->{_var}{nextCacheFlush}; - $session->db->setRow("userSession","sessionId", $self->{_var}); -} - -#------------------------------------------------------------------- - -=head2 switchAdminOn ( ) - -Enables admin mode. - -=cut - -sub switchAdminOn { - my $self = shift; - $self->{_var}{adminOn} = 1; - my $session = $self->session; - $session->cache->set($self->getId, $self->{_var}, $session->setting->get('sessionTimeout')); - delete $self->{_var}{nextCacheFlush}; - $self->session->db->setRow("userSession","sessionId", $self->{_var}); -} - - -1; diff --git a/t/Session.t b/t/Session.t index 822cabe32..810a97ab5 100644 --- a/t/Session.t +++ b/t/Session.t @@ -16,6 +16,7 @@ use WebGUI::Session; use WebGUI::User; use Test::More; +use Test::Deep; my $session = WebGUI::Test->session; @@ -76,7 +77,10 @@ my $id = $session->getId; my ($count) = $session->db->quickArray("select count(*) from userSession where sessionId=?", [$id]); is($count, 1, "created an user session entry in the database"); -my $varSession = WebGUI::Session->open($session->config); +my $env; +$session->request->env->{REMOTE_ADDR} = '192.168.0.34'; + +my $varSession = WebGUI::Session->open($session->config, $session->request->env); WebGUI::Test->addToCleanup($varSession); my $varTime = time(); isnt($varSession->scratch->get('webguiCsrfToken'), $token, '... calling new without sessionId creates a new token'); @@ -93,16 +97,120 @@ is($varSession->get('adminOn'), 0, "adminOn is off by default"); ##retest is($varSession->get('lastIP'), '192.168.0.34', "lastIP fetched"); -my $var2 = WebGUI::Session->open($session->config, undef, 'illegalSessionIdThatIsTooLong'); -# '1234567890123456789012' -isa_ok($var2, 'WebGUI::Session', 'invalid sessionId will still produce a Session object'); -($count) = $session->db->quickArray("select count(*) from userSession where sessionId=?",[$var2->getId]); -is($count, 0, "object store of sessionId does not match database record"); -my $var2Id = $var2->getId; -$var2->end; -my $idToDelete = substr $var2Id,0,22; -($count) = $session->db->quickArray("select count(*) from userSession where sessionId=?",[$idToDelete]); -is($count, 1, "Unable to delete database record for Var object with invalid sessionId"); +my $illegalSessionId = 'illegalSessionIdThatIsTooLong'; +# '1234567890123456789012' +my $varIllegal = WebGUI::Session->open($session->config, undef, ); +WebGUI::Test->addToCleanup($varIllegal); + +isa_ok($varIllegal, 'WebGUI::Session', 'invalid sessionId will still produce a Session object'); +ok($session->id->valid($varIllegal->getId), 'valid ID created for the new session, when bad Id was suggested'); +ok(index($varIllegal->getId, $illegalSessionId) == -1, 'illegal session was not truncated to make the new Id'); + +$session->request->env->{REMOTE_ADDR} = '10.0.0.5'; +my $varCopy = WebGUI::Session->open($session->config, $session->request->env, $varSession->getId); +is($varCopy->scratch->get('webguiCsrfToken'), $varSession->scratch->get('webguiCsrfToken'), 'opening a copy of a user session did not change the CSRF token'); + +cmp_deeply( + $varCopy, + methods( + ['get', 'sessionId'] => $varSession->get('sessionId'), + ['get', 'userId'] => $varSession->get('userId'), + ['get', 'adminOn'] => $varSession->get('adminOn'), + ), + 'similar methods in copy of original var object' +); + +is($varCopy->get('lastIP'), '10.0.0.5', "lastIP set on copy"); + +my $varSessionId = $varSession->getId; +$varSession->end; +($count) = $session->db->quickArray("select count(*) from userSession where sessionId=?",[$varSession->getId]); +ok($count == 0,"end() removes current entry from database"); + +{ + my $sessionId = 'nonExistantIdButValid0'; + # '1234567890123456789012' + my $testSession = WebGUI::Session->open($session->config, undef, $sessionId); + my $guard = WebGUI::Test->cleanupGuard($testSession); + isa_ok($testSession, 'WebGUI::Session', 'non-existant sessionId will still produce a Var object'); + is($testSession->getId, $sessionId, 'user session Id set to non-existant Id'); +} + +{ + my $expire = WebGUI::Session->open($session->config); + my $guard = WebGUI::Test->cleanupGuard($expire); + $expire->switchAdminOn; + # jury rig the database and the cache to expire + my $expire_time = $expire->get('lastPageView') - 1; + $session->db->write("update userSession set userId=?, expires=? where sessionId=?", [3, $expire_time, $expire->getId]); + $session->user({userId => 3}); + my $copyOfSession = { %{ $expire->get() } }; + $copyOfSession->{expires} = $expire_time; + $session->cache->set($expire->getId, $copyOfSession); + + my $copy = WebGUI::Session->open($session->config, undef, $expire->getId); + my $guard2 = WebGUI::Test->cleanupGuard($copy); + is $copy->getId, $expire->getId, 'new Var object has correct id'; + isnt $copy->isAdminOn, $expire->isAdminOn, 'new adminOn not equal to old adminOn'; + is $copy->isAdminOn, 0, 'new Var object has default adminOn'; + isnt $copy->get('userId'), 3, 'new userId not equal to old userId'; +} + +{ + ##Var objects for noFuss tests + my $trial = WebGUI::Session->open($session->config); + my $expiring = WebGUI::Session->open($session->config); + my $guard = WebGUI::Test->cleanupGuard($trial, $expiring); + $session->db->write("update userSession set expires=? where sessionId=?", [$expiring->get('lastPageView')-5, $expiring->getId]); + $expiring->{_var}{expires} = $expiring->get('lastPageView')-5; + + ##Valid fetch with no fuss + my $varTest = WebGUI::Session->open($session->config, $session->request->env, $trial->getId, 1); + my $guard2 = WebGUI::Test->cleanupGuard($varTest); + + cmp_deeply( + $varTest, + methods( + ['get', 'sessionId'] => $trial->getId, + ['get', 'userId'] => 1, + ['get', 'adminOn'] => 0, + ['get', 'lastIP'] => '127.0.0.1', + ['get', 'expires'] => $trial->get('expires'), + ['get', 'lastPageView'] => $trial->get('lastPageView'), + ), + 'fetching a valid session with noFuss does not update the object info' + ); + + ##Test a valid fetch + my $expired = WebGUI::Session->open($session->config, undef, $expiring->getId, 1); + my $guard3 = WebGUI::Test->cleanupGuard($expired); + + cmp_deeply( + $expired, + methods( + ['get', 'sessionId'] => $expiring->getId, + ['get', 'userId'] => 1, + ['get', 'adminOn'] => 0, + ['get', 'lastIP'] => '127.0.0.1', + ['get', 'lastPageView'] => $expiring->get('lastPageView'), + ['get', 'expires'] => $expiring->get('expires'), + ), + 'fetching a valid session with noFuss does not update the object info, even if it has expired' + ); + +} + +my $varId4 = 'idDoesNotExist00779988'; +# '1234567890123456789012' +my $varTest = WebGUI::Session->open($session->config, undef, $varId4, 1); +WebGUI::Test->addToCleanup($varTest); +isa_ok($varTest, "WebGUI::Session", "non-existant Id with noFuss returns a valid object..."); +is($varTest->getId, $varId4, "...and we got our requested Id"); + +$varTest->start(3, $varTest->getId); +is($varTest->get('userId'), 3, 'userId set via start'); +$varTest->start("", $varTest->getId); +is($varTest->get('userId'), 1, 'calling start with null userId returns default user (visitor)'); done_testing; diff --git a/t/Session/Var.t b/t/Session/Var.t deleted file mode 100644 index 20dcaea4c..000000000 --- a/t/Session/Var.t +++ /dev/null @@ -1,216 +0,0 @@ -#------------------------------------------------------------------- -# WebGUI is Copyright 2001-2009 Plain Black Corporation. -#------------------------------------------------------------------- -# Please read the legal notices (docs/legal.txt) and the license -# (docs/license.txt) that came with this distribution before using -# this software. -#------------------------------------------------------------------- -# http://www.plainblack.com info@plainblack.com -#------------------------------------------------------------------- - -use strict; - -use WebGUI::Test; -use WebGUI::Session; -use WebGUI::Session::Var; - -use Test::More tests => 44; # increment this value for each test you create -use Test::Deep; - -my $session = WebGUI::Test->session; - -ok($session->var->getId ne "", "getId()"); -cmp_ok($session->var->get("lastPageView"), '>', 0, "get(lastPageView)"); -is($session->var->isAdminOn, 0, "isAdminOn()"); -$session->var->switchAdminOn; -is($session->var->isAdminOn, 1, "switchAdminOn()"); -$session->var->switchAdminOff; -is($session->var->isAdminOn, 0, "switchAdminOff()"); - -my $token = $session->scratch->get('webguiCsrfToken'); -ok( $token, 'CSRF token set'); -ok( $session->id->valid($token), '...is a valid GUID'); - -my $id = $session->var->getId; -my ($count) = $session->db->quickArray("select count(*) from userSession where sessionId=?",[$id]); -is($count, 1, "created an user session entry in the database"); - -my $env = $session->request->env; -$env->{REMOTE_ADDR} = '192.168.0.34'; - -my $var = WebGUI::Session::Var->new($session); -my $varTime = time(); -my $varExpires = $varTime + $session->setting->get('sessionTimeout'); -isa_ok($var, 'WebGUI::Session::Var', 'new returns Var object'); -isnt($session->scratch->get('webguiCsrfToken'), $token, '... calling new without sessionId creates a new token'); -$token = $session->scratch->get('webguiCsrfToken'); - -cmp_ok(abs($var->get('lastPageView') - $varTime), '<=', 1, 'lastPageView set correctly'); -cmp_ok(abs($var->get('expires') - $varExpires), '<=', 1, 'expires set correctly'); - -is($var->get('userId'), 1, 'default userId is 1'); - -is($var->get('sessionId'), $var->getId, "get('sessionId') and getId return the same thing"); -isnt($var->getId, $session->var->getId, "a sessionId different from our Session's var sessionId was created"); -is($var->getId, $session->getId, 'SessionId set to userSessionId from var'); - -is($var->get('adminOn'), $var->isAdminOn, "get('adminOn') and isAdminOn return the same thing"); -is($var->get('adminOn'), 0, "adminOn is off by default"); ##retest - -is($var->get('lastIP'), '192.168.0.34', "lastIP fetched"); - -isa_ok($var->session, 'WebGUI::Session', 'session method returns a Session object'); -is($var->session->getId, $session->getId, 'session method returns our Session object'); - -sleep(2); -$env->{REMOTE_ADDR} = '10.0.5.5'; - -#Grab a more recent version of our user session object -$varTime = time(); -my $var2 = WebGUI::Session::Var->new($session, $session->getId); -$varExpires = $varTime + $session->setting->get('sessionTimeout'); -is($var2->session->scratch->get('webguiCsrfToken'), $token, 'opening a new user session did not change the CSRF token'); - -cmp_deeply( - $var2, - methods( - ['get', 'sessionId'] => $var->get('sessionId'), - ['get', 'userId'] => $var->get('userId'), - ['get', 'adminOn'] => $var->get('adminOn'), - ), - 'similar methods in copy of original var object' -); - -cmp_ok(abs($var2->get('lastPageView') - $varTime), '<=', 1, 'lastPageView set correctly on copy'); -cmp_ok(abs($var2->get('expires') - $varExpires), '<=', 1, 'expires set correctly on copy'); -is($var2->get('lastIP'), '10.0.5.5', "lastIP set on copy"); - -my $var2Id = $var2->getId; -$var2->end; -($count) = $session->db->quickArray("select count(*) from userSession where sessionId=?",[$var2->getId]); -ok($count == 0,"end() removes current entry from database"); -$var->end; - -$var2 = WebGUI::Session::Var->new($session, 'illegalSessionIdThatIsTooLong'); -# '1234567890123456789012' -isa_ok($var2, 'WebGUI::Session::Var', 'invalid sessionId will still produce a Var object'); -($count) = $session->db->quickArray("select count(*) from userSession where sessionId=?",[$var2->getId]); -is($count, 0, "object store of sessionId does not match database record"); -$var2Id = $var2->getId; -$var2->end; -my $idToDelete = substr $var2Id,0,22; -($count) = $session->db->quickArray("select count(*) from userSession where sessionId=?",[$idToDelete]); -is($count, 1, "Unable to delete database record for Var object with invalid sessionId"); - -my $varId3 = 'nonExistantIdButValid0'; -# '1234567890123456789012' -$var = WebGUI::Session::Var->new($session, $varId3); -isa_ok($var, 'WebGUI::Session::Var', 'non-existant sessionId will still produce a Var object'); -is($var->getId, $varId3, 'user session Id set to non-existant Id'); -is($session->getId, $varId3, 'session Id set to non-existant Id'); - -cmp_deeply( - $var, - methods( - ['get', 'sessionId'] => $varId3, - ['get', 'userId'] => 1, - ['get', 'adminOn'] => 0, - ['get', 'lastIP'] => '10.0.5.5', - ), - 'non-existant Id returns default values' -); - -$var->end; - -##Grab a new Var object that we'll expire. We'll detect the expiration -##by looking for admin status and userId -$var2 = WebGUI::Session::Var->new($session); -$var2->switchAdminOn; - -# jury rig the database and the cache to expire -$session->db->write("update userSession set userId=? where sessionId=?", - [3, $var2->getId]); -$session->db->write("update userSession set expires=? where sessionId=?", - [$var2->get('lastPageView')-1, $var2->getId]); -my %copyOfVar2 = %{$var2->{_var}}; -$copyOfVar2{expires} = $var2->get('lastPageView')-1; -$copyOfVar2{userId} = 3; -$session->cache->set($var2->getId, \%copyOfVar2); - -my $var3 = WebGUI::Session::Var->new($session, $var2->getId); -is $var3->getId, $var2->getId, 'new Var object has correct id'; -isnt $var3->isAdminOn, $var2->isAdminOn, 'new adminOn not equal to old adminOn'; -is $var3->isAdminOn, 0, 'new Var object has default adminOn'; -isnt $var3->get('userId'), 3, 'new userId not equal to old userId'; -$var2->end; -$var3->end; - -##Var objects for noFuss tests -my $var4 = WebGUI::Session::Var->new($session); -my $varExpiring = WebGUI::Session::Var->new($session); -$session->db->write("update userSession set expires=? where sessionId=?", - [$varExpiring->get('lastPageView')-1, $varExpiring->getId]); -$varExpiring->{_var}{expires} = $varExpiring->get('lastPageView')-1; - -sleep 1; - -$env->{REMOTE_ADDR} = '127.0.0.1'; - -##Test a valid fetch -my $varTest = WebGUI::Session::Var->new($session, $var4->getId, 1); - -cmp_deeply( - $varTest, - methods( - ['get', 'sessionId'] => $var4->getId, - ['get', 'userId'] => 1, - ['get', 'adminOn'] => 0, - ['get', 'lastIP'] => '10.0.5.5', - ['get', 'expires'] => $var4->get('expires'), - ['get', 'lastPageView'] => $var4->get('lastPageView'), - ), - 'fetching a valid session with noFuss does not update the object info' -); - -$varTest->end; -$var4->end; - -##Test a valid fetch -$varTest = WebGUI::Session::Var->new($session, $varExpiring->getId, 1); - -cmp_deeply( - $varTest, - methods( - ['get', 'sessionId'] => $varExpiring->getId, - ['get', 'userId'] => 1, - ['get', 'adminOn'] => 0, - ['get', 'lastIP'] => '10.0.5.5', - ['get', 'lastPageView'] => $varExpiring->get('lastPageView'), - ['get', 'expires'] => $varExpiring->get('expires'), - ), - 'fetching a valid session with noFuss does not update the object info, even if it has expired' -); - -$varExpiring->end; -$varTest->end; - -my $varId4 = 'idDoesNotExist00779988'; -# '1234567890123456789012' -$varTest = WebGUI::Session::Var->new($session, $varId4, 1); -isa_ok($varTest, "WebGUI::Session::Var", "non-existant Id with noFuss returns a valid object..."); -is($varTest->getId, $varId4, "...and we got our requested Id"); - -$varTest->start(3, $varTest->getId); -is($varTest->get('userId'), 3, 'userId set via start'); -$varTest->start("", $varTest->getId); -is($varTest->get('userId'), 1, 'calling start with null userId returns default user (visitor)'); - -END { - - foreach my $varObj ($var, $var2, $var3, $var4, $varExpiring, $varTest) { - if (defined $varObj and ref $varObj eq 'WebGUI::Session::Var') { - $varObj->end(); - } - } - $session->db->write("delete from userSession where sessionId=?",[$idToDelete]); -} From b5d263e693f9dc64fa3862f7a7487d9fba256f39 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Wed, 17 Nov 2010 16:20:59 -0800 Subject: [PATCH 13/16] Fix Auth and SSO. --- lib/WebGUI/Auth/WebGUI.pm | 6 +++--- lib/WebGUI/Operation/SSO.pm | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/WebGUI/Auth/WebGUI.pm b/lib/WebGUI/Auth/WebGUI.pm index eb9f0d29c..1177b48de 100644 --- a/lib/WebGUI/Auth/WebGUI.pm +++ b/lib/WebGUI/Auth/WebGUI.pm @@ -701,9 +701,9 @@ WebGUI::Asset::Template->newById($self->session,$self->getSetting('accountActiva $mail->addFooter; $mail->queue; $self->user->status("Deactivated"); - $session->var->end($session->var->get("sessionId")); - $session->var->start(1,$session->getId); - my $u = WebGUI::User->new($session,1); + $session->end(); + $session->start(1, $session->getId); + my $u = WebGUI::User->new($session, 1); $self->{user} = $u; $self->logout; return $self->www_displayLogin($i18n->get('check email for validation','AuthWebGUI')); diff --git a/lib/WebGUI/Operation/SSO.pm b/lib/WebGUI/Operation/SSO.pm index 9075b3db0..cfdff5c32 100644 --- a/lib/WebGUI/Operation/SSO.pm +++ b/lib/WebGUI/Operation/SSO.pm @@ -40,8 +40,8 @@ sub www_ssoViaSessionId { else { my ($userId) = $session->db->quickArray("select userId from userSession where sessionId=?",[$sessionId]); if (defined $userId && $userId ne "") { - $session->var->end; - $session->var->start($userId, $sessionId); + $session->end; + $session->start($userId, $sessionId); } } } From c4553012d1ce185c3c1d5cf6d2d40ce546ca759f Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Wed, 17 Nov 2010 16:34:11 -0800 Subject: [PATCH 14/16] Syntax clean. --- lib/WebGUI/Admin.pm | 2 +- lib/WebGUI/Asset.pm | 17 +++++++++-------- lib/WebGUI/Asset/File.pm | 4 ++-- lib/WebGUI/Asset/File/Image.pm | 4 ++-- lib/WebGUI/Asset/File/ZipArchive.pm | 6 +++--- lib/WebGUI/Asset/Redirect.pm | 4 ++-- lib/WebGUI/Asset/Shortcut.pm | 14 +++++++------- lib/WebGUI/Asset/Sku/Product.pm | 4 ++-- lib/WebGUI/Asset/Snippet.pm | 4 ++-- lib/WebGUI/Asset/Template.pm | 4 ++-- lib/WebGUI/Asset/Template/Parser.pm | 2 +- lib/WebGUI/Asset/Wobject/Article.pm | 4 ++-- lib/WebGUI/Asset/Wobject/Calendar.pm | 2 +- lib/WebGUI/Asset/Wobject/Dashboard.pm | 10 +++++----- lib/WebGUI/Asset/Wobject/DataForm.pm | 4 ++-- lib/WebGUI/Asset/Wobject/HttpProxy.pm | 2 +- lib/WebGUI/Asset/Wobject/Layout.pm | 4 ++-- lib/WebGUI/Asset/Wobject/Matrix.pm | 4 ++-- lib/WebGUI/Asset/Wobject/MultiSearch.pm | 4 ++-- lib/WebGUI/Asset/Wobject/Navigation.pm | 2 +- lib/WebGUI/Asset/Wobject/SQLReport.pm | 4 ++-- lib/WebGUI/Asset/Wobject/SyndicatedContent.pm | 4 ++-- lib/WebGUI/Asset/Wobject/Thingy.pm | 4 ++-- lib/WebGUI/AssetExportHtml.pm | 6 +++--- lib/WebGUI/Auth.pm | 2 +- lib/WebGUI/Content/Asset.pm | 4 ++-- lib/WebGUI/Macro/AdminBar.pm | 2 +- lib/WebGUI/Macro/AdminText.pm | 2 +- lib/WebGUI/Macro/AdminToggle.pm | 2 +- lib/WebGUI/Macro/AssetProxy.pm | 6 +++--- lib/WebGUI/Macro/EditableToggle.pm | 2 +- lib/WebGUI/Macro/FilePump.pm | 2 +- lib/WebGUI/Macro/L_loginBox.pm | 2 +- lib/WebGUI/Middleware/WGAccess.pm | 2 +- lib/WebGUI/Operation/ActiveSessions.pm | 2 +- lib/WebGUI/Operation/Admin.pm | 6 +++--- lib/WebGUI/Operation/User.pm | 2 +- lib/WebGUI/PassiveProfiling.pm | 4 ++-- lib/WebGUI/Role/Asset/Comments.pm | 2 +- lib/WebGUI/Session.pm | 1 - lib/WebGUI/Session/Http.pm | 7 ++++--- lib/WebGUI/Test/Mechanize.pm | 2 +- lib/WebGUI/VersionTag.pm | 2 +- .../Workflow/Activity/DeleteExpiredSessions.pm | 2 +- 44 files changed, 88 insertions(+), 87 deletions(-) diff --git a/lib/WebGUI/Admin.pm b/lib/WebGUI/Admin.pm index ad1036c68..442ea532d 100644 --- a/lib/WebGUI/Admin.pm +++ b/lib/WebGUI/Admin.pm @@ -754,7 +754,7 @@ sub www_view { $var->{backToSiteUrl} = $url->page; # temporary! We are now in admin mode! - $session->var->switchAdminOn; + $session->switchAdminOn; # Add vars for AdminBar $var->{adminPlugins} = $self->getAdminPluginTemplateVars; diff --git a/lib/WebGUI/Asset.pm b/lib/WebGUI/Asset.pm index fc7fa7f22..b5bf4fb18 100644 --- a/lib/WebGUI/Asset.pm +++ b/lib/WebGUI/Asset.pm @@ -454,7 +454,7 @@ The missing URL. sub addMissing { my $self = shift; my $assetUrl = shift; - return undef unless ($self->session->var->isAdminOn); + return undef unless ($self->session->isAdminOn); my $i18n = WebGUI::International->new($self->session, "Asset"); my $output = $i18n->get("missing page query"); $output .= '
    @@ -592,14 +592,15 @@ to SSL. sub checkView { my $self = shift; return $self->session->privilege->noAccess() unless $self->canView; - my ($conf, $var, $http) = $self->session->quick(qw(config var http)); + my $session = $self->session; + my ($conf, $http) = $self->session->quick(qw(config http)); if ($conf->get("sslEnabled") && $self->get("encryptPage") && ! $self->session->request->secure) { # getUrl already changes url to https if 'encryptPage' $http->setRedirect($self->getUrl); $http->sendHeader; return "chunked"; } - elsif ($var->isAdminOn && $self->get("state") =~ /^trash/) { # show em trash + elsif ($session->isAdminOn && $self->get("state") =~ /^trash/) { # show em trash my $queryFrag = "func=manageTrash"; if ($self->session->form->process('revision')) { $queryFrag .= ";revision=".$self->session->form->process('revision'); @@ -608,7 +609,7 @@ sub checkView { $http->sendHeader; return "chunked"; } - elsif ($var->isAdminOn && $self->get("state") =~ /^clipboard/) { # show em clipboard + elsif ($session->isAdminOn && $self->get("state") =~ /^clipboard/) { # show em clipboard my $queryFrag = "func=manageClipboard"; if ($self->session->form->process('revision')) { $queryFrag .= ";revision=".$self->session->form->process('revision'); @@ -679,7 +680,7 @@ sub dispatch { my $session = $self->session; my $state = $self->get('state'); ##Only allow interaction with assets in certain states - return if $state ne 'published' && $state ne 'archived' && !$session->var->isAdminOn; + return if $state ne 'published' && $state ne 'archived' && !$session->isAdminOn; my $func = $session->form->param('func') || 'view'; my $viewing = $func eq 'view' ? 1 : 0; my $sub = $self->can('www_'.$func); @@ -1594,7 +1595,7 @@ Returns a toolbar with a set of icons that hyperlink to functions that delete, e sub getToolbar { my $self = shift; - return undef unless $self->canEdit && $self->session->var->isAdminOn; + return undef unless $self->canEdit && $self->session->isAdminOn; return $self->{_toolbar} if (exists $self->{_toolbar}); my $userUiLevel = $self->session->user->profileField("uiLevel"); @@ -2370,7 +2371,7 @@ sub processTemplate { } if (! Exception::Class->caught() ) { $var = { %{ $var }, %{ $self->getMetaDataAsTemplateVariables } }; - $var->{'controls'} = $self->getToolbar if $session->var->isAdminOn; + $var->{'controls'} = $self->getToolbar if $session->isAdminOn; $var->{'assetIdHex'} = $session->id->toHex($self->getId); my %vars = ( %{$self->get}, @@ -2681,7 +2682,7 @@ The default view method for any asset that doesn't define one. Under all normal sub view { my $self = shift; - if ($self->session->var->isAdminOn) { + if ($self->session->isAdminOn) { return $self->getToolbar.' '.$self->getTitle; } else { return ""; diff --git a/lib/WebGUI/Asset/File.pm b/lib/WebGUI/Asset/File.pm index 28c871024..12b8ec526 100644 --- a/lib/WebGUI/Asset/File.pm +++ b/lib/WebGUI/Asset/File.pm @@ -564,7 +564,7 @@ Generate the view method for the Asset, and handle caching. sub view { my $self = shift; - if (!$self->session->var->isAdminOn && $self->get("cacheTimeout") > 10) { + if (!$self->session->isAdminOn && $self->get("cacheTimeout") > 10) { my $out = $self->session->cache->get($self->getViewCacheKey); return $out if $out; } @@ -574,7 +574,7 @@ sub view { $var{fileIcon} = $self->getFileIconUrl; $var{fileSize} = Number::Format::format_bytes($self->get("assetSize")); my $out = $self->processTemplate(\%var,undef,$self->{_viewTemplate}); - if (!$self->session->var->isAdminOn && $self->get("cacheTimeout") > 10) { + if (!$self->session->isAdminOn && $self->get("cacheTimeout") > 10) { $self->session->cache->set($self->getViewCacheKey, $out, $self->get("cacheTimeout")); } return $out; diff --git a/lib/WebGUI/Asset/File/Image.pm b/lib/WebGUI/Asset/File/Image.pm index 38613c581..c117bf05f 100644 --- a/lib/WebGUI/Asset/File/Image.pm +++ b/lib/WebGUI/Asset/File/Image.pm @@ -210,7 +210,7 @@ sub view { my $session = $self->session; my $cache = $session->cache; my $cacheKey = $self->getWwwCacheKey('view'); - if (!$session->var->isAdminOn && $self->cacheTimeout > 10) { + if (!$session->isAdminOn && $self->cacheTimeout > 10) { my $out = $cache->get( $cacheKey ); return $out if $out; } @@ -233,7 +233,7 @@ sub view { $var{annotateJs} = $crop_js . $domMe; $var{parameters} .= sprintf(q{ id="%s"}, $self->getId); my $out = $self->processTemplate(\%var,undef,$self->{_viewTemplate}); - if (!$session->var->isAdminOn && $self->cacheTimeout > 10) { + if (!$session->isAdminOn && $self->cacheTimeout > 10) { $cache->set( $cacheKey, $out, $self->get("cacheTimeout") ); } return $out; diff --git a/lib/WebGUI/Asset/File/ZipArchive.pm b/lib/WebGUI/Asset/File/ZipArchive.pm index e2bd61571..fc62fb3ca 100644 --- a/lib/WebGUI/Asset/File/ZipArchive.pm +++ b/lib/WebGUI/Asset/File/ZipArchive.pm @@ -209,7 +209,7 @@ sub view { my $self = shift; my $cache = $self->session->cache; my $cacheKey = $self->getWwwCacheKey('view'); - if (!$self->session->var->isAdminOn && $self->cacheTimeout > 10) { + if (!$self->session->isAdminOn && $self->cacheTimeout > 10) { my $out = $cache->get( $cacheKey ); return $out if $out; } @@ -232,7 +232,7 @@ sub view { $var{noInitialPage} = $i18n->get('noInitialPage'); $var{noFileSpecified} = $i18n->get('noFileSpecified'); my $out = $self->processTemplate(\%var,undef,$self->{_viewTemplate}); - if (!$self->session->var->isAdminOn && $self->cacheTimeout > 10) { + if (!$self->session->isAdminOn && $self->cacheTimeout > 10) { $cache->set( $cacheKey, $out, $self->cacheTimeout); } return $out; @@ -268,7 +268,7 @@ Web facing method which is the default view page. This method does a sub www_view { my $self = shift; return $self->session->privilege->noAccess() unless $self->canView; - if ($self->session->var->isAdminOn) { + if ($self->session->isAdminOn) { return $self->session->asset($self->getContainer)->www_view; } $self->session->http->setRedirect($self->getFileUrl($self->showPage)); diff --git a/lib/WebGUI/Asset/Redirect.pm b/lib/WebGUI/Asset/Redirect.pm index a5ad06223..d250aed76 100644 --- a/lib/WebGUI/Asset/Redirect.pm +++ b/lib/WebGUI/Asset/Redirect.pm @@ -99,7 +99,7 @@ Display the redirect url when in admin mode. sub view { my $self = shift; - if ($self->session->var->isAdminOn) { + if ($self->session->isAdminOn) { return $self->getToolbar.' '.$self->getTitle.' '.$self->redirectUrl; } else { @@ -121,7 +121,7 @@ sub www_view { my $i18n = WebGUI::International->new($self->session, "Asset_Redirect"); my $url = $self->redirectUrl; WebGUI::Macro::process($self->session, \$url); - if ($self->session->var->isAdminOn() && $self->canEdit) { + if ($self->session->isAdminOn() && $self->canEdit) { return $self->getAdminConsole->render($i18n->get("what do you want to do with this redirect").'
    • '.$i18n->get("go to the redirect url").'
    • diff --git a/lib/WebGUI/Asset/Shortcut.pm b/lib/WebGUI/Asset/Shortcut.pm index a2739ec65..a347b9068 100644 --- a/lib/WebGUI/Asset/Shortcut.pm +++ b/lib/WebGUI/Asset/Shortcut.pm @@ -239,7 +239,7 @@ Shortcut that the Visitor would see, or their own. sub discernUserId { my $self = shift; - return ($self->canManage && $self->session->var->isAdminOn) ? '1' : $self->session->user->userId; + return ($self->canManage && $self->session->isAdminOn) ? '1' : $self->session->user->userId; } #------------------------------------------------------------------- @@ -464,7 +464,7 @@ admin mode is on. sub _overridesCacheTag { my $self = shift; #cache by userId, assetId of this shortcut, and whether adminMode is on or not. - return ["shortcutOverrides", $self->getId, $self->session->user->userId, $self->session->var->isAdminOn]; + return ["shortcutOverrides", $self->getId, $self->session->user->userId, $self->session->isAdminOn]; } #------------------------------------------------------------------- @@ -488,7 +488,7 @@ sub getOverrides { my $overridesRef = $cache->get($self->_overridesCacheTag); ##If admin mode is not on, and the cache is valid, and not expired, and the user object was not updated, ##return the cached value. - if ( ! $session->var->isAdminOn + if ( ! $session->isAdminOn && $overridesRef && $overridesRef->{cacheNotExpired} && $overridesRef->{userLastUpdated} >= $u->get('lastUpdated')) { @@ -591,7 +591,7 @@ sub getShortcutByCriteria { if ($assetId) { $scratchId = "Shortcut_" . $assetId; if($self->session->scratch->get($scratchId) && !$self->disableContentLock) { - unless ($self->session->var->isAdminOn) { + unless ($self->session->isAdminOn) { return WebGUI::Asset->newById($self->session, $self->session->scratch->get($scratchId)); } } @@ -990,8 +990,8 @@ sub www_getUserPrefsForm { my @fielden = $self->getPrefFieldsToShow; my $f = WebGUI::HTMLForm->new($self->session,extras=>' onsubmit="submitForm(this,\''.$self->getId.'\',\''.$self->getUrl.'\');return false;"'); $f->raw(''); - my $allowedToSave = ( ! $session->var->isAdminOn && $self->getParent->canPersonalize ) - || ( $session->var->isAdminOn && $session->user->isInGroup($session->setting->get('groupIdAdminUser')) ); + my $allowedToSave = ( ! $session->isAdminOn && $self->getParent->canPersonalize ) + || ( $session->isAdminOn && $session->user->isInGroup($session->setting->get('groupIdAdminUser')) ); if ($allowedToSave) { $f->hidden( -name => 'func', @@ -1090,7 +1090,7 @@ sub www_saveUserPrefs { my $self = shift; my $session = $self->session; return '' unless $self->getParent->canPersonalize - || ( $session->var->isAdminOn && $session->user->isInGroup($session->setting->get('groupIdAdminUser')) ); + || ( $session->isAdminOn && $session->user->isInGroup($session->setting->get('groupIdAdminUser')) ); my @fellowFields = $self->getPrefFieldsToShow; my %data = (); $self->uncacheOverrides; diff --git a/lib/WebGUI/Asset/Sku/Product.pm b/lib/WebGUI/Asset/Sku/Product.pm index df8c8f6eb..521f6ea2d 100644 --- a/lib/WebGUI/Asset/Sku/Product.pm +++ b/lib/WebGUI/Asset/Sku/Product.pm @@ -1654,7 +1654,7 @@ sub view { my $session = $self->session; my $cache = $session->cache; my $cacheKey = $self->getWwwCacheKey( 'view' ); - if (!$session->var->isAdminOn && $self->get("cacheTimeout") > 10){ + if (!$session->isAdminOn && $self->get("cacheTimeout") > 10){ my $out = $cache->get( $cacheKey ); return $out if $out; } @@ -1856,7 +1856,7 @@ sub view { $var{continueShoppingUrl} = $self->getUrl; my $out = $self->processTemplate(\%var,undef,$self->{_viewTemplate}); - if (!$self->session->var->isAdminOn && $self->cacheTimeout > 10 && $self->{_hasAddedToCart} != 1){ + if (!$self->session->isAdminOn && $self->cacheTimeout > 10 && $self->{_hasAddedToCart} != 1){ $cache->set( $cacheKey, $out, $self->cacheTimeout ); } return $out; diff --git a/lib/WebGUI/Asset/Snippet.pm b/lib/WebGUI/Asset/Snippet.pm index aeaf109d4..9d5955dbc 100644 --- a/lib/WebGUI/Asset/Snippet.pm +++ b/lib/WebGUI/Asset/Snippet.pm @@ -253,7 +253,7 @@ sub view { my $session = $self->session; my $versionTag = WebGUI::VersionTag->getWorking($session, 1); my $noCache = - $session->var->isAdminOn + $session->isAdminOn || $self->cacheTimeout <= 10 || ($versionTag && $versionTag->getId eq $self->tagId); my $cacheKey = $self->getWwwCacheKey('view', $calledAsWebMethod); @@ -265,7 +265,7 @@ sub view { ? $self->snippetPacked : $self->snippet ; - $output = $self->getToolbar.$output if ($session->var->isAdminOn && !$calledAsWebMethod); + $output = $self->getToolbar.$output if ($session->isAdminOn && !$calledAsWebMethod); if ($self->processAsTemplate) { $output = WebGUI::Asset::Template->processRaw($session, $output, $self->get); } diff --git a/lib/WebGUI/Asset/Template.pm b/lib/WebGUI/Asset/Template.pm index e7df99f65..1f55e6c68 100644 --- a/lib/WebGUI/Asset/Template.pm +++ b/lib/WebGUI/Asset/Template.pm @@ -564,13 +564,13 @@ sub process { my $i18n = WebGUI::International->new($session, 'Asset_Template'); $session->log->warn('process called on template in trash: '.$self->getId .'. The template was called through this url: '.$session->asset->url); - return $session->var->isAdminOn ? $i18n->get('template in trash') : ''; + return $session->isAdminOn ? $i18n->get('template in trash') : ''; } elsif ($self->state =~ /^clipboard/) { my $i18n = WebGUI::International->new($session, 'Asset_Template'); $session->log->warn('process called on template in clipboard: '.$self->getId .'. The template was called through this url: '.$session->asset->url); - return $session->var->isAdminOn ? $i18n->get('template in clipboard') : ''; + return $session->isAdminOn ? $i18n->get('template in clipboard') : ''; } # Return a JSONinfied version of vars if JSON is the only requested content type. diff --git a/lib/WebGUI/Asset/Template/Parser.pm b/lib/WebGUI/Asset/Template/Parser.pm index b37f606f5..2771736d6 100644 --- a/lib/WebGUI/Asset/Template/Parser.pm +++ b/lib/WebGUI/Asset/Template/Parser.pm @@ -39,7 +39,7 @@ sub addSessionVars { $vars->{"session.user.username"} = $self->session->user->username; $vars->{"session.user.firstDayOfWeek"} = $self->session->user->profileField("firstDayOfWeek"); $vars->{"session.config.extrasurl"} = $self->session->url->extras(); - $vars->{"session.var.adminOn"} = $self->session->var->isAdminOn; + $vars->{"session.var.adminOn"} = $self->session->isAdminOn; $vars->{"session.setting.companyName"} = $self->session->setting->get("companyName"); $vars->{"session.setting.anonymousRegistration"} = $self->session->setting->get("anonymousRegistration"); my $forms = $self->session->form->paramsHashRef(); diff --git a/lib/WebGUI/Asset/Wobject/Article.pm b/lib/WebGUI/Asset/Wobject/Article.pm index ce08d4bd1..b963285c6 100644 --- a/lib/WebGUI/Asset/Wobject/Article.pm +++ b/lib/WebGUI/Asset/Wobject/Article.pm @@ -320,7 +320,7 @@ returns the output. sub view { my $self = shift; my $cache = $self->session->cache; - if (!$self->session->var->isAdminOn && $self->cacheTimeout > 10 && !$self->session->form->process("overrideTemplateId") && + if (!$self->session->isAdminOn && $self->cacheTimeout > 10 && !$self->session->form->process("overrideTemplateId") && !$self->session->form->process($self->paginateVar) && !$self->session->form->process("makePrintable")) { my $out = $cache->get($self->getViewCacheKey); return $out if $out; @@ -384,7 +384,7 @@ sub view { } $p->appendTemplateVars(\%var); my $out = $self->processTemplate(\%var,undef,$self->{_viewTemplate}); - if (!$self->session->var->isAdminOn && $self->cacheTimeout > 10 && !$self->session->form->process("overrideTemplateId") && + if (!$self->session->isAdminOn && $self->cacheTimeout > 10 && !$self->session->form->process("overrideTemplateId") && !$self->session->form->process($self->paginateVar) && !$self->session->form->process("makePrintable")) { $cache->set($self->getViewCacheKey, $out, $self->cacheTimeout); } diff --git a/lib/WebGUI/Asset/Wobject/Calendar.pm b/lib/WebGUI/Asset/Wobject/Calendar.pm index af0aa67ad..c5aa3c1f4 100644 --- a/lib/WebGUI/Asset/Wobject/Calendar.pm +++ b/lib/WebGUI/Asset/Wobject/Calendar.pm @@ -957,7 +957,7 @@ sub view { ##### Process the template # Add any global variables # Admin - if ($self->session->var->isAdminOn) { + if ($self->session->isAdminOn) { $var->{'admin'} = 1; $var->{'adminControls'} = $self->getToolbar; } diff --git a/lib/WebGUI/Asset/Wobject/Dashboard.pm b/lib/WebGUI/Asset/Wobject/Dashboard.pm index 4d67eaa48..512078b6e 100644 --- a/lib/WebGUI/Asset/Wobject/Dashboard.pm +++ b/lib/WebGUI/Asset/Wobject/Dashboard.pm @@ -121,7 +121,7 @@ Dashboard that Visitor would see, or their own. sub discernUserId { my $self = shift; - return ($self->canManage && $self->session->var->isAdminOn) ? '1' : $self->session->user->userId; + return ($self->canManage && $self->session->isAdminOn) ? '1' : $self->session->user->userId; } #------------------------------------------------------------------- @@ -243,7 +243,7 @@ turned on. sub isManaging { my $self = shift; - return 1 if ($self->canManage && $self->session->var->isAdminOn()); + return 1 if ($self->canManage && $self->session->isAdminOn()); return 0; } @@ -415,7 +415,7 @@ sub view { } } } - $vars{showAdmin} = ($self->session->var->isAdminOn && $self->canEdit); + $vars{showAdmin} = ($self->session->isAdminOn && $self->canEdit); $vars{"dragger.init"} = ' \n\n|, diff --git a/t/Session/Http.t b/t/Session/Http.t index 92237691d..3f5684e11 100644 --- a/t/Session/Http.t +++ b/t/Session/Http.t @@ -32,7 +32,7 @@ use Test::MockObject::Extends; ##try and implement the mod_perl cookie handling code. $http = Test::MockObject::Extends->new($http); my $cookieName = $session->config->getCookieName; -my $varId = $session->var->getId(); +my $varId = $session->getId(); $http->mock( getCookies => sub { return {$cookieName => $varId} } ); diff --git a/t/Workflow/Activity/DeleteExpiredSessions.t b/t/Workflow/Activity/DeleteExpiredSessions.t index 8355e426d..b9378c94b 100644 --- a/t/Workflow/Activity/DeleteExpiredSessions.t +++ b/t/Workflow/Activity/DeleteExpiredSessions.t @@ -93,7 +93,7 @@ is ($newSessionCount, $sessionCount+2, 'two of the sessions were deleted'); is ($newScratchCount, $scratchCount+2, 'scratch from both sessions cleaned up'); foreach my $testSession (@sessions) { - $testSession->var->end; + $testSession->end; $testSession->close; } From 5812d88bd4da952a51dd90f609d5ab3778a0b7fd Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Thu, 18 Nov 2010 08:41:49 -0800 Subject: [PATCH 16/16] No using Var! --- t/Macro/UsersOnline.t | 1 - 1 file changed, 1 deletion(-) diff --git a/t/Macro/UsersOnline.t b/t/Macro/UsersOnline.t index 108922b34..6858060d2 100644 --- a/t/Macro/UsersOnline.t +++ b/t/Macro/UsersOnline.t @@ -15,7 +15,6 @@ use JSON; use WebGUI::Test; use WebGUI::International; use WebGUI::Session; -use WebGUI::Session::Var; use WebGUI::User; use WebGUI::Macro::UsersOnline;