From 99c2064126978f377f8fb23f61a2db3e201a33c1 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Tue, 23 Jul 2024 06:39:07 -0400 Subject: [PATCH] Bug 9596: (QA follow-up) Only find a given patron once Signed-off-by: Katrin Fischer --- misc/cronjobs/longoverdue.pl | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/misc/cronjobs/longoverdue.pl b/misc/cronjobs/longoverdue.pl index 9aa5242616..e92aea4cb6 100755 --- a/misc/cronjobs/longoverdue.pl +++ b/misc/cronjobs/longoverdue.pl @@ -464,15 +464,18 @@ foreach my $startrange (sort keys %$lost) { $sth_items->execute($startrange, $endrange, $lostvalue); $count=0; ITEM: while (my $row=$sth_items->fetchrow_hashref) { + my $patron; if( $filter_borrower_categories ) { - my $category = uc Koha::Patrons->find( $row->{borrowernumber} )->categorycode(); + $patron ||= Koha::Patrons->find( $row->{borrowernumber} ); + my $category = uc $patron->categorycode(); next ITEM unless ( $category_to_process{ $category } ); } if ($filter_branches) { my $lib; for ($circ_control_pref) { if ( $_ eq 'PatronLibrary' ) { - $lib = Koha::Patrons->find( $row->{borrowernumber} )->branchcode(); + $patron ||= Koha::Patrons->find( $row->{borrowernumber} ); + $lib = $patron->branchcode(); } elsif ( $_ eq 'PickupLibrary' ) { $lib = C4::Context->userenv->{'branch'}; } else { # ( $_ eq 'ItemHomeLibrary' ) @@ -492,7 +495,7 @@ foreach my $startrange (sort keys %$lost) { if ( $charge && $charge eq $lostvalue ) { LostItem( $row->{'itemnumber'}, 'cronjob', $mark_returned ); } elsif ( $mark_returned ) { - my $patron = Koha::Patrons->find( $row->{borrowernumber} ); + $patron ||= Koha::Patrons->find( $row->{borrowernumber} ); MarkIssueReturned($row->{borrowernumber},$row->{itemnumber},undef,$patron->privacy) } } -- 2.39.5