Bug 43069: Don't match every patron when no duplicate-match fields apply

check_for_existing_matches() called Koha::Patrons->search(undef) when
PatronDuplicateMatchingAddFields left no usable field to match on,
which matches every patron instead of none.

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Pedro Amorim 2026-07-14 09:27:21 +00:00 committed by Lucas Gass
parent 2adc268464
commit 8697929514
No known key found for this signature in database
GPG Key ID: 60B447398B0D36CA
1 changed files with 4 additions and 0 deletions

View File

@ -749,6 +749,10 @@ sub check_for_existing_matches {
$match_conditions->{$field} = $new_patron_data->{$field} if $new_patron_data->{$field};
}
# Without any usable conditions, Koha::Patrons->search would run
# unfiltered and match every patron in the system.
return { 'duplicate_found' => 0 } unless $match_conditions && %$match_conditions;
my $patrons = Koha::Patrons->search($match_conditions);
if ( $patrons->count > 0 ) {
return {