From 22221feaa273dec75d23732933ea29b51e031044 Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Tue, 14 Jul 2026 09:27:21 +0000 Subject: [PATCH] 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 Signed-off-by: Martin Renvoize Signed-off-by: Pedro Amorim --- Koha/Patrons.pm | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Koha/Patrons.pm b/Koha/Patrons.pm index 2bafea19ea..425893e8d4 100644 --- a/Koha/Patrons.pm +++ b/Koha/Patrons.pm @@ -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 {