Bug 20763: Remove unecessary Koha::Patron fetch
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Mon, 28 May 2018 19:36:54 +0000 (16:36 -0300)
committerNick Clemens <nick@bywatersolutions.com>
Mon, 4 Jun 2018 12:58:53 +0000 (12:58 +0000)
If $borrowernumber is not set, there is no userenv.
So let's pick the library code set in the userenv instead of fetching
the Koha::Patron->branchcode from DB

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
opac/opac-suggestions.pl

index c29278c..19493aa 100755 (executable)
@@ -198,12 +198,7 @@ my $patron_reason_loop = GetAuthorisedValues("OPAC_SUG");
 if ( C4::Context->preference("AllowPurchaseSuggestionBranchChoice") ) {
     my $branchcode = $input->param('branchcode') || q{};
 
-    if ( !$branchcode && $borrowernumber ) {
-        my $patron = Koha::Patrons->find($borrowernumber);
-        $branchcode = $patron->branchcode;
-    }
-
-    if (   !$branchcode
+    if ( !$branchcode
         && C4::Context->userenv
         && C4::Context->userenv->{branch} )
     {