From 9a2a998ad087228579957ea8a74025c0296ae1c4 Mon Sep 17 00:00:00 2001 From: Lucas Gass Date: Tue, 29 Apr 2025 17:27:05 +0000 Subject: [PATCH] Bug 39644: Skip processing guarantor if already seen To test: 1. In k-t-d try loading both member/moremember.pl and circ/circulation.pl for a patron with many guarantors. 2. Note the load times. 3. APPLY PATCH 4. Load times should now be reduced pretty significantly. 5. prove -v /kohadevbox/koha/t/db_dependent/Koha/Patron.t 6. No behavior should change. Signed-off-by: Roman Dolny Signed-off-by: Martin Renvoize --- Koha/Patron.pm | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Koha/Patron.pm b/Koha/Patron.pm index 55e06599574..2797ea92f1c 100644 --- a/Koha/Patron.pm +++ b/Koha/Patron.pm @@ -634,6 +634,9 @@ sub relationships_debt { my $non_issues_charges = 0; my $seen = $include_this_patron ? {} : { $self->id => 1 }; # For tracking members already added to the total foreach my $guarantor (@guarantors) { + if ( !$only_this_guarantor && $seen->{ $guarantor->id } ) { + next; + } $non_issues_charges += $guarantor->account->non_issues_charges if $include_guarantors && !$seen->{ $guarantor->id }; -- 2.49.0