Bugzilla – Attachment 182990 Details for
Bug 40082
PatronDuplicateMatchingAddFields isn't respected in the OPAC or the API
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 40082: Move the duplicate matching logic to the Koha::Patrons class
Bug-40082-Move-the-duplicate-matching-logic-to-the.patch (text/plain), 2.34 KB, created by
Matt Blenkinsop
on 2025-06-05 12:49:46 UTC
(
hide
)
Description:
Bug 40082: Move the duplicate matching logic to the Koha::Patrons class
Filename:
MIME Type:
Creator:
Matt Blenkinsop
Created:
2025-06-05 12:49:46 UTC
Size:
2.34 KB
patch
obsolete
>From f0096b7dfbf819a5393c00ac5f0e7bcae5c03998 Mon Sep 17 00:00:00 2001 >From: Matt Blenkinsop <matt.blenkinsop@openfifth.co.uk> >Date: Thu, 5 Jun 2025 13:38:37 +0100 >Subject: [PATCH] Bug 40082: Move the duplicate matching logic to the > Koha::Patrons class > >--- > Koha/Patrons.pm | 23 +++++++++++++++++++++++ > members/memberentry.pl | 13 ++++--------- > 2 files changed, 27 insertions(+), 9 deletions(-) > >diff --git a/Koha/Patrons.pm b/Koha/Patrons.pm >index 3156f4f60e7..35c22518bab 100644 >--- a/Koha/Patrons.pm >+++ b/Koha/Patrons.pm >@@ -647,6 +647,29 @@ sub extended_attributes_config { > }; > } > >+=head3 check_for_existing_matches >+ >+=cut >+ >+sub check_for_existing_matches { >+ my ( $self, $new_patron_data ) = @_; >+ >+ my @duplicate_match_fields = split '\|', C4::Context->preference('PatronDuplicateMatchingAddFields'); >+ my $match_conditions; >+ for my $field (@duplicate_match_fields) { >+ $match_conditions->{$field} = $new_patron_data->{$field} if $new_patron_data->{$field}; >+ } >+ >+ my $patrons = Koha::Patrons->search($match_conditions); >+ if ( $patrons->count > 0 ) { >+ return { >+ 'duplicate_found' => 1, >+ 'matching_patrons' => $patrons >+ }; >+ } >+ return { 'duplicate_found' => 0 }; >+} >+ > =head3 _type > > =cut >diff --git a/members/memberentry.pl b/members/memberentry.pl >index 5846b3b1c60..af96eef4977 100755 >--- a/members/memberentry.pl >+++ b/members/memberentry.pl >@@ -252,18 +252,13 @@ if ( $op eq 'cud-insert' || $op eq 'edit_form' || $op eq 'cud-save' || $op eq 'd > } > } > >-# Test uniqueness of surname, firstname and dateofbirth >+#Test uniqueness of fields in PatronDuplicateMatchingAddFields > if ( ( $op eq 'cud-insert' ) and !$nodouble ) { >- my @dup_fields = split '\|', C4::Context->preference('PatronDuplicateMatchingAddFields'); >- my $conditions; >- for my $f (@dup_fields) { >- $conditions->{$f} = $newdata{$f} if $newdata{$f}; >- } > $nodouble = 1; >- my $patrons = Koha::Patrons->search($conditions); >- if ( $patrons->count > 0 ) { >+ my $match_result = Koha::Patrons->check_for_existing_matches( \%newdata ); >+ if ( $match_result->{duplicate_found} ) { > $nodouble = 0; >- $check_patron = $patrons->next; >+ $check_patron = $match_result->{matching_patrons}->next; > $check_member = $check_patron->borrowernumber; > } > } >-- >2.48.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 40082
:
182990
|
182991
|
182992
|
182993
|
182994
|
182995
|
182996
|
182997