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 <roman.dolny@jezuici.pl>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
Lucas Gass 2025-04-29 17:27:05 +00:00 committed by Katrin Fischer
parent b16a015235
commit 8bd72af1ff
No known key found for this signature in database
GPG Key ID: 0EF6E2C03357A834
1 changed files with 3 additions and 0 deletions

View File

@ -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 };