From c1cbc66cdcf0fabb16a75985015bab4d8ea7619f Mon Sep 17 00:00:00 2001 From: Mark Tompsett Date: Tue, 17 Sep 2013 23:39:36 -0400 Subject: [PATCH] Bug 10900 - Incorrect calling conventions accessing C4::Context There were multiple calling conventions for C4::Context's set_userenv routine. So the following commands were used to find discrepancies: grep "C4::Context::set_userenv" `find .` grep "C4::Context->set_userenv" `find .` It was recommended that it should be ->, and so a shift was added to the routine to properly ignore the object that is passed. --- C4/Auth.pm | 10 +++++----- C4/Context.pm | 1 + installer/InstallAuth.pm | 4 ++-- t/db_dependent/Circulation.t | 2 +- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/C4/Auth.pm b/C4/Auth.pm index 1e17e59..e9f459b 100644 --- a/C4/Auth.pm +++ b/C4/Auth.pm @@ -642,7 +642,7 @@ sub checkauth { C4::Context->_new_userenv($sessionID); my ($ip, $lasttime, $sessiontype); if ($session){ - C4::Context::set_userenv( + C4::Context->set_userenv( $session->param('number'), $session->param('id'), $session->param('cardnumber'), $session->param('firstname'), $session->param('surname'), $session->param('branch'), @@ -915,7 +915,7 @@ sub checkauth { if ($persona){ $session->param('persona',1); } - C4::Context::set_userenv( + C4::Context->set_userenv( $session->param('number'), $session->param('id'), $session->param('cardnumber'), $session->param('firstname'), $session->param('surname'), $session->param('branch'), @@ -1146,7 +1146,7 @@ sub check_api_auth { my $session = get_session($sessionID); C4::Context->_new_userenv($sessionID); if ($session) { - C4::Context::set_userenv( + C4::Context->set_userenv( $session->param('number'), $session->param('id'), $session->param('cardnumber'), $session->param('firstname'), $session->param('surname'), $session->param('branch'), @@ -1306,7 +1306,7 @@ sub check_api_auth { $session->param('ip',$session->remote_addr()); $session->param('lasttime',time()); } - C4::Context::set_userenv( + C4::Context->set_userenv( $session->param('number'), $session->param('id'), $session->param('cardnumber'), $session->param('firstname'), $session->param('surname'), $session->param('branch'), @@ -1385,7 +1385,7 @@ sub check_cookie_auth { my $session = get_session($sessionID); C4::Context->_new_userenv($sessionID); if ($session) { - C4::Context::set_userenv( + C4::Context->set_userenv( $session->param('number'), $session->param('id'), $session->param('cardnumber'), $session->param('firstname'), $session->param('surname'), $session->param('branch'), diff --git a/C4/Context.pm b/C4/Context.pm index 739a0ec..25a06ce 100644 --- a/C4/Context.pm +++ b/C4/Context.pm @@ -1111,6 +1111,7 @@ set_userenv is called in Auth.pm #' sub set_userenv { + shift @_; my ($usernum, $userid, $usercnum, $userfirstname, $usersurname, $userbranch, $branchname, $userflags, $emailaddress, $branchprinter, $persona)= @_; my $var=$context->{"activeuser"} || ''; my $cell = { diff --git a/installer/InstallAuth.pm b/installer/InstallAuth.pm index 0015a14..1aafe70 100644 --- a/installer/InstallAuth.pm +++ b/installer/InstallAuth.pm @@ -250,7 +250,7 @@ sub checkauth { new CGI::Session( "driver:File;serializer:yaml", $sessionID, { Directory => '/tmp' } ); if ( $session->param('cardnumber') ) { - C4::Context::set_userenv( + C4::Context->set_userenv( $session->param('number'), $session->param('id'), $session->param('cardnumber'), @@ -312,7 +312,7 @@ sub checkauth { #Only superlibrarian should have access to this page. #Since if it is a user, it is supposed that there is a borrower table #And thus that data structure is loaded. - my $hash = C4::Context::set_userenv( + my $hash = C4::Context->set_userenv( 0, 0, C4::Context->config('user'), C4::Context->config('user'), C4::Context->config('user'), "", diff --git a/t/db_dependent/Circulation.t b/t/db_dependent/Circulation.t index 1ef6271..bc0bd41 100755 --- a/t/db_dependent/Circulation.t +++ b/t/db_dependent/Circulation.t @@ -77,7 +77,7 @@ is( diag('Now, set a userenv'); C4::Context->_new_userenv('xxx'); -C4::Context::set_userenv(0,0,0,'firstname','surname', 'MPL', 'Midway Public Library', '', '', ''); +C4::Context->set_userenv(0,0,0,'firstname','surname', 'MPL', 'Midway Public Library', '', '', ''); is(C4::Context->userenv->{branch}, 'MPL', 'userenv set'); # Userenv set, PickupLibrary -- 1.7.9.5