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: Pedro Amorim <pedro.amorim@openfifth.co.uk>
This commit is contained in:
Pedro Amorim 2026-07-14 09:27:21 +00:00
parent e87732a1b6
commit 22221feaa2
No known key found for this signature in database
GPG Key ID: 06B75BA7F3894D55
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 {