From c8c1b99612bedada7b13b15eadf4972b823a5818 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joonas=20Kylm=C3=A4l=C3=A4?= Date: Wed, 4 Nov 2020 17:05:28 +0200 Subject: [PATCH] Bug 26132: (follow-up) Fix broken code in TooMany function The $checkouts variable was not defined in the PatronLibrary case at all and in the else case the SQL join was totally missing. To test: 1) Without this patch notice prove t/db_dependent/Circulation/TooMany.t fails 2) With this patch notice prove t/db_dependent/Circulation/TooMany.t succeeds --- C4/Circulation.pm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index c66d5d5e52..6880a8288c 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -543,10 +543,11 @@ sub TooMany { $checkouts = $patron->checkouts->search( { 'me.branchcode' => $branch} ); } elsif (C4::Context->preference('CircControl') eq 'PatronLibrary') { - ; # if branch is the patron's home branch, then count all loans by patron + $checkouts = $patron->checkouts; # if branch is the patron's home branch, then count all loans by patron } else { $checkouts = $patron->checkouts->search( - { 'item.homebranch' => $branch} ); + { 'item.homebranch' => $branch}, + { prefetch => 'item' } ); } my $checkout_count = $checkouts->count; -- 2.11.0