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 <gmcharlt@gmail.com>
This commit is contained in:
Michael Hafen 2009-09-14 09:07:57 -06:00 committed by Henri-Damien LAURENT
parent dfa8b99296
commit dbc0161cdc
1 changed files with 4 additions and 0 deletions

View File

@ -1447,6 +1447,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 =