From 4f9d622917ae7df30b2c9cbb718f40ad5aa0d3a9 Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Thu, 27 Jan 2022 10:46:32 +0000 Subject: [PATCH] Bug 29954: Make new_userenv and unset_userenv consistent Content-Type: text/plain; charset=utf-8 Remove the underscore; not a private routine. --- C4/Context.pm | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/C4/Context.pm b/C4/Context.pm index 241589e7b5..8baf029861 100644 --- a/C4/Context.pm +++ b/C4/Context.pm @@ -747,44 +747,41 @@ sub set_userenv { return $cell; } -=head2 _new_userenv +=head2 new_userenv - C4::Context->_new_userenv($session); # FIXME: This calling style is wrong for what looks like an _internal function + C4::Context->new_userenv($session); Builds a hash for user environment variables. This hash shall be cached for future use: if you call Cuserenv> twice, you will get the same hash without real DB access -_new_userenv is called in Auth.pm +new_userenv is called in Auth.pm =cut -#' -sub _new_userenv -{ - shift; # Useless except it compensates for bad calling style - my ($sessionID)= @_; - $context->{"activeuser"}=$sessionID; +sub new_userenv { + my ( $class, $sessionID ) = @_; + $context->{activeuser} = $sessionID; } -=head2 _unset_userenv +=head2 unset_userenv - C4::Context->_unset_userenv; + C4::Context->unset_userenv( $sessionID ); -Destroys the hash for activeuser user environment variables. +Destroys the hash for activeuser user environment variables if sessionID matches. =cut -#' - -sub _unset_userenv -{ - my ($sessionID)= @_; - undef $context->{"activeuser"} if ($context->{"activeuser"} eq $sessionID); +sub unset_userenv { + my ( $class, $sessionID )= @_; + if( defined($sessionID) && defined($context->{activeuser}) && + $context->{activeuser} eq $sessionID ) + { + undef $context->{activeuser}; + } } - =head2 get_versions C4::Context->get_versions -- 2.20.1