From 2ce4f1c36dae03e8f603d0e73b1b14870b5c2828 Mon Sep 17 00:00:00 2001 From: Janusz Kaczmarek Date: Tue, 17 Dec 2024 13:31:07 +0000 Subject: [PATCH] Bug 38729: Linker should consider diacritics MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Currently, Koha linker does not pay attention to the diacritics while linking--the decision about linking is taken based on the results of search in the search engine (be it Zebra or Elasticsearch) which are diacritics insensitive. As a consequence, "Brückner, Karl" could be erroneously linked to "Bruckner, Karl", in case when "Brückner, Karl" did not exist in the authority file, or no link would be made in case when both "Brückner, Karl" and "Bruckner, Karl" existed in the authority file and LinkerModule is set to 'default'. Test plan: ========== 1. Make sure that LinkerModule system preference is set to default. 2. Create an authority record of type PERSO_NAME with a name containing diacritics (e.g. "Brückner, Karl" , or "Rąkowski, Albin" etc.). 3. Edit an existing or create a new bibliographic record and put in a personal name field (100, 600, 700) that name without diacritics. 4. Click "Link authorities automatically" -- the two different names will be linked, which is wrong. 5. Create a second authority record with name form exactly from the bibliographic record (without diacritics). 6. Edit an existing or create a new bibliographic record and put in a personal name field (100, 600, 700) the name without diacritics. 7. Click "Link authorities automatically" -- you should get a message "More than one local match found. Possibly a duplicate authority!". 8. Apply the patch ; restart_all. 9. Choose another name pair with and without diacritics. Repeat p. 3-4. The bibliographic field should not be linked this time. 10. With the new pair, repeat p. 5.-7. The bibliographic field should now be correctly linked. Sponsored-by: Ignatianum University in Cracow --- C4/Heading.pm | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/C4/Heading.pm b/C4/Heading.pm index 653cd9636d..b40da97eee 100644 --- a/C4/Heading.pm +++ b/C4/Heading.pm @@ -148,7 +148,7 @@ sub authorities { my $self = shift; my $skipmetadata = shift; my ( $results, $total ) = _search( $self, 'match-heading', $skipmetadata ); - return $results; + return $self->_filter_exact($results); } =head2 preferred_authorities @@ -266,6 +266,29 @@ sub _search { } +=head2 _filter_exact + +=cut + +sub _filter_exact { + my $self = shift; + my $results = shift; + my $exact_matched_auths = []; + for my $matched_auth (@$results) { + my $auth = Koha::Authorities->find( $matched_auth->{authid} ); + next unless $auth; + my $authrec = $auth->record; + my $auth_tag_to_report = Koha::Authority::Types->find( $self->{auth_type} )->auth_tag_to_report; + my $auth_heading_field = $authrec->field($auth_tag_to_report); + $auth_heading_field->set_tag( $self->field->tag ); + my $auth_heading = C4::Heading->new_from_field($auth_heading_field); + if ( $auth_heading->search_form eq $self->search_form ) { + push @$exact_matched_auths, $matched_auth; + } + } + return $exact_matched_auths; +} + =head1 INTERNAL FUNCTIONS =head2 _marc_format_handler -- 2.39.5