Bugzilla – Attachment 180200 Details for
Bug 39503
Linker should always respect thesaurus with LinkerConsiderThesaurus on
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 39503: Bug 39503 - Linker should always respect thesaurus with LinkerConsiderThesaurus on
Bug-39503-Bug-39503---Linker-should-always-respect.patch (text/plain), 3.68 KB, created by
Roman Dolny
on 2025-04-01 14:25:23 UTC
(
hide
)
Description:
Bug 39503: Bug 39503 - Linker should always respect thesaurus with LinkerConsiderThesaurus on
Filename:
MIME Type:
Creator:
Roman Dolny
Created:
2025-04-01 14:25:23 UTC
Size:
3.68 KB
patch
obsolete
>From 2fa5e41a50aff5e9225c8869a32e39b099506e51 Mon Sep 17 00:00:00 2001 >From: Janusz Kaczmarek <januszop@gmail.com> >Date: Wed, 29 Jan 2025 00:23:41 +0100 >Subject: [PATCH] Bug 39503: Bug 39503 - Linker should always respect thesaurus > with LinkerConsiderThesaurus on > >With bug 30280 and subsequent patches we attempt to respect the >thesaurus indication when linking with LinkerConsiderThesaurus on. >However, there are still cases when we link wrong. > >This happens when thesaurus in bibliographic field 6XX is defined by >subfield $2. In such a case the authority record should have 008/11 = 'z' >and, according to https://www.loc.gov/marc/authority/ad008.html >(cf. comment for 008/11 = 'z': "A MARC code for the conventions used to >formulate the heading *may* be contained in subfield $f"), may or may have >thesaurus declared in 040 $f. > >This is why we make a second search attempt in C4::Heading::_search, >but doing so we have to make sure that the resulting authority >record has not a different thesaurus declared in 040 $f. (Note >that 008/11 and 040 $f are indexed with the same search >field: subject-heading-thesaurus. So we search for the >second time in the same search field but with >'notdefined' == 008/11='z' instead of the original >thesaurus taken from subfield $2 of the bibliographic >field 6XX.) This means we have to explicitly check the >content of 040 $f of the resulting authority record. > >Test plan: >========== >1. Turn on the LinkerConsiderThesaurus systempreference. >2. Create an authority record (e.g. TOPIC_TERM) with 008/11 = 'z' and > 040 $f containing a thesaurus indication (e.g. 'kaba'), and a term > in field 150 $a (e.g. Early music). >3. Edit a bibliographic record: in field 650 put 2nd indicator '7', > the term 'Early music' in $a, and a different thesaurus code in $2 > (e.g. 'dbn'). Click the 'Link authorities automatically' button. > Note that 650 'Early music' (dbn) has been linked with and authority > record 'Early music' (kaba). This is wrong. >4. Apply the patch ; restart_all. >5. Repeat p. 3. Now the 650 'Early music' (dbn) has not been linked to > an authority record (650 - No matching authority found.) > >Signed-off-by: Roman Dolny <roman.dolny@jezuici.pl> >--- > C4/Heading.pm | 22 +++++++++++++++++++++- > 1 file changed, 21 insertions(+), 1 deletion(-) > >diff --git a/C4/Heading.pm b/C4/Heading.pm >index 79001ecf62..3eb2bbcec1 100644 >--- a/C4/Heading.pm >+++ b/C4/Heading.pm >@@ -232,7 +232,7 @@ sub _search { > && none { $_ eq $thesaurus } ( > 'lcsh', 'lcac', 'mesh', 'nal', > 'notspecified', 'cash', 'rvm', 'sears', >- 'aat' >+ 'aat', 'notdefined' > ) > ) > { >@@ -244,6 +244,26 @@ sub _search { > 'AuthidAsc' > ); > ( $matched_auths, $total ) = $searcher->search_auth_compat( $search_query, 0, 20, $skipmetadata ); >+ >+ # We have to make sure that we do not link with an authority record >+ # controlling the same term but from a different thesaurus. >+ # This means we have to check the content of 040 $f of the authority record. >+ my $matched_auths_exact = []; >+ for my $matched_auth (@$matched_auths) { >+ my $auth = Koha::Authorities->find( $matched_auth->{authid} ); >+ unless ($auth) { >+ $total--; >+ next; >+ } >+ my $auth_rec = $auth->record; >+ my $s040f = $auth_rec->subfield( '040', 'f' ) // ''; >+ if ( !$s040f || $s040f eq $thesaurus ) { >+ push @{$matched_auths_exact}, $matched_auth; >+ } else { >+ $total--; >+ } >+ } >+ $matched_auths = $matched_auths_exact; > } > return ( $matched_auths, $total ); > >-- >2.39.5
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 39503
:
180082
|
180131
|
180200
|
180201
|
180844
|
180902
|
180903
|
180940
|
180941
|
181205
|
182182
|
182183