From 5de6ec3c155ece9ac9589ca20d97ba9aee098608 Mon Sep 17 00:00:00 2001 From: Michael Hafen Date: Mon, 14 Sep 2009 09:07:57 -0600 Subject: [PATCH] Avoid potentially unnecessary database call in Auth Auth, after verifying the session/logging in the user, calls to the database to get the users borrowernumber. This call is probably unnecessary because borrowernumber is part of userenv. Check userenv before going to the database. Signed-off-by: Galen Charlton --- C4/Auth.pm | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/C4/Auth.pm b/C4/Auth.pm index d73f19b692..7574f9eb7f 100644 --- a/C4/Auth.pm +++ b/C4/Auth.pm @@ -1468,6 +1468,10 @@ sub haspermission { sub getborrowernumber { my ($userid) = @_; + my $userenv = C4::Context->userenv; + if ( defined( $userenv ) && ref( $userenv ) eq 'HASH' && $userenv->{number} ) { + return $userenv->{number}; + } my $dbh = C4::Context->dbh; for my $field ( 'userid', 'cardnumber' ) { my $sth = -- 2.39.5