From 1bf99e3e5c8a9dc9540a117979b5311808b3e8a2 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Mon, 20 Mar 2023 15:44:17 +0000 Subject: [PATCH] Bug 33277: Do not search using thesaurus when linking non 6XX fields This patch sets thesaurus as undefined when linking any field except 6XX This fixes the case where authrotiy records don't have the thesaurus defined Consequently - this means that Koha does not support multiple thesaurus records for authorities outside of subjects i.e. Using the default linker, and having both an LCSH and Sears record for 'Shakespeare,William' A 100 entry will find two results and the heading won't be linked. Previously we always linked to the LCSH To test: 1 - Import the attached auths and biblio (from bug 33159 comment 24) 2 - Set system preferences: RequireChoosingExistingAuthority - don't require AutoCreateAuthorities - don't generate CatalogModuleRelink - Do LinkerKeepStale - Don't LinkerModule - default LinkerRelink - do 3 - Edit the imported bib 4 - Save it 5 - Headings are not linked except 600 6 - Apply patch 7 - Restart all 8 - Edit and save record 9 - Headings are successfully linked Signed-off-by: Frank Hansen Signed-off-by: Marcel de Rooy Signed-off-by: Tomas Cohen Arazi (cherry picked from commit d73f56736669afb522f58f5e2856a5fad54bfc64) Signed-off-by: Matt Blenkinsop --- C4/Heading/MARC21.pm | 2 +- t/db_dependent/Heading.t | 3 --- t/db_dependent/Heading_MARC21.t | 4 ++-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/C4/Heading/MARC21.pm b/C4/Heading/MARC21.pm index 87d825bb4c..652c300282 100644 --- a/C4/Heading/MARC21.pm +++ b/C4/Heading/MARC21.pm @@ -339,7 +339,7 @@ sub parse_heading { my $thesaurus = $tag =~ m/6../ ? _get_subject_thesaurus($field) - : "lcsh"; # use 'lcsh' for names, UT, etc. + : undef; # We can't know the thesaurus for non-subject fields my $search_heading = _get_search_heading( $field, $field_info->{'subfields'} ); my $display_heading = diff --git a/t/db_dependent/Heading.t b/t/db_dependent/Heading.t index 7aa14c94aa..db7c8ffc14 100755 --- a/t/db_dependent/Heading.t +++ b/t/db_dependent/Heading.t @@ -114,7 +114,6 @@ subtest "_search tests" => sub { $terms = $search_query->{query}->{bool}->{must}; $expected_terms = [ { term => { 'match-heading.ci_raw' => 'Yankovic, Al 1959' } }, - { term => { 'subject-heading-thesaurus.ci_raw' => 'a' } }, ]; is_deeply( $terms, $expected_terms, "Search formed as expected for a non-subject field with single punctuation mark"); @@ -124,7 +123,6 @@ subtest "_search tests" => sub { $terms = $search_query->{query}->{bool}->{must}; $expected_terms = [ { term => { 'match-heading.ci_raw' => 'Yankovic, Al 1959' } }, - { term => { 'subject-heading-thesaurus.ci_raw' => 'a' } }, ]; is_deeply( $terms, $expected_terms, "Search formed as expected for a non-subject field with double punctuation, hyphen+comma"); @@ -134,7 +132,6 @@ subtest "_search tests" => sub { $terms = $search_query->{query}->{bool}->{must}; $expected_terms = [ { term => { 'match-heading.ci_raw' => 'Tolkien, J.R.R' } }, - { term => { 'subject-heading-thesaurus.ci_raw' => 'a' } }, ]; is_deeply( $terms, $expected_terms, "Search formed as expected for a non-subject field with double punctuation, period+comma "); diff --git a/t/db_dependent/Heading_MARC21.t b/t/db_dependent/Heading_MARC21.t index 32bd0a07cc..9f94cf2234 100755 --- a/t/db_dependent/Heading_MARC21.t +++ b/t/db_dependent/Heading_MARC21.t @@ -25,12 +25,12 @@ SKIP: { $heading = C4::Heading->new_from_field($field); is($heading->display_form(), 'The dark is rising ;', 'Display form generation'); is($heading->search_form(), 'The dark is rising', 'Search form generation'); - is($heading->{thesaurus}, 'lcsh', 'Thesaurus generation'); + ok( !defined $heading->{thesaurus}, 'Thesaurus is not generated outside of 6XX fields'); $field = MARC::Field->new( '100', '1', '', a => 'Yankovic, Al', d => '1959-' ); $heading = C4::Heading->new_from_field($field); is($heading->display_form(), 'Yankovic, Al 1959-', 'Display form generation'); is($heading->search_form(), 'Yankovic, Al 1959', 'Search form generation'); - is($heading->{thesaurus}, 'lcsh', 'Thesaurus generation'); + ok( !defined $heading->{thesaurus}, 'Thesaurus is not generated outside of 6XX fields'); } -- 2.39.5