Bug 35125: Respect LinkerConsiderThesaurus in get_link
This patch adds a new key 'notconsidered' to the authority cache when
linking to avoid doubling when creating new authorities and wishing
to ignore thesaurus
To test:
0 - Set LinkerConsiderThesaurus to "don't"
1 - Set AutCreateAuthorities to generate
2 - Set AutLinkBiblios to Do
3 - Set CataloguingModuleRelink to Do
4 - Save a new record in Koha with the same randomized heading repeated
but from 3 different authority sources
ensure source is defined by indicators only and by field $2 once
ensure the heading is random so that no matches will be found
5 - Confirm each authority is linked to a new unique authority
6 - Apply patch, restart all
7 - Repeat 4 with a new subject heading
8 - Confirm all headings are linked to the same authority
Signed-off-by: Phil Ringnalda <phil@chetcolibrary.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
(cherry picked from commit 1894fc5101)
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
parent
f66e0c6a82
commit
88d9ea0ea8
|
|
@ -31,6 +31,7 @@ sub get_link {
|
|||
my $search_form = $heading->search_form();
|
||||
my $auth_type = $heading->auth_type();
|
||||
my $thesaurus = $heading->{thesaurus} || 'notdefined';
|
||||
$thesaurus = 'notconsidered' unless C4::Context->preference('LinkerConsiderThesaurus');
|
||||
my $authid;
|
||||
my $fuzzy = 0;
|
||||
my $match_count;
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ my $schema = $builder->schema();
|
|||
$schema->storage->txn_begin;
|
||||
|
||||
subtest 'Test caching in get_link and update_cache' => sub {
|
||||
plan tests => 13;
|
||||
plan tests => 16;
|
||||
|
||||
my @tags = C4::Context->preference('marcflavour') eq 'UNIMARC' ? (601,'j',602,'a') : (650,'a',655,'a');
|
||||
|
||||
|
|
@ -53,6 +53,8 @@ subtest 'Test caching in get_link and update_cache' => sub {
|
|||
my $subject_field5 = MARC::Field->new($tags[0],0,7,$tags[1]=>'Science fiction','2'=>'sao');
|
||||
my $subject_field6 = MARC::Field->new($tags[0],0,7,$tags[1]=>'Science fiction','2'=>'sao');
|
||||
my $subject_field7 = MARC::Field->new($tags[0],0,4,$tags[1]=>'Science fiction');
|
||||
my $subject_field8 = MARC::Field->new($tags[0],0,7,$tags[1]=>'Science fiction','2'=>'oth');
|
||||
my $subject_field9 = MARC::Field->new($tags[0],0,3,$tags[1]=>'Science fiction');
|
||||
my $genre_field = MARC::Field->new($tags[2],0,2,$tags[3]=>'Science fiction');
|
||||
# Can we build a heading from it?
|
||||
my $subject_heading = C4::Heading->new_from_field( $subject_field, q{} );
|
||||
|
|
@ -62,8 +64,11 @@ subtest 'Test caching in get_link and update_cache' => sub {
|
|||
my $subject_heading5 = C4::Heading->new_from_field( $subject_field5, q{} );
|
||||
my $subject_heading6 = C4::Heading->new_from_field( $subject_field6, q{} );
|
||||
my $subject_heading7 = C4::Heading->new_from_field( $subject_field7, q{} );
|
||||
my $subject_heading8 = C4::Heading->new_from_field( $subject_field8, q{} );
|
||||
my $subject_heading9 = C4::Heading->new_from_field( $subject_field9, q{} );
|
||||
my $genre_heading = C4::Heading->new_from_field( $genre_field, q{} );
|
||||
|
||||
t::lib::Mocks::mock_preference('LinkerConsiderThesaurus',1);
|
||||
|
||||
# Now test to see if C4::Linker can find it.
|
||||
my $linker = C4::Linker::Default->new();
|
||||
|
|
@ -92,6 +97,19 @@ subtest 'Test caching in get_link and update_cache' => sub {
|
|||
$linker->get_link($subject_heading7);
|
||||
is( keys %{$linker->{cache}},6, "Eighth (matching) term added to cache because of thesaurus source not specified (2nd indicator is 4)");
|
||||
|
||||
t::lib::Mocks::mock_preference('LinkerConsiderThesaurus',0);
|
||||
|
||||
$linker->get_link($subject_heading);
|
||||
is( keys %{$linker->{cache}},7, "First term added to cache because cache key now has 'notconsidered' for thesaurus");
|
||||
|
||||
$linker->get_link($subject_heading8);
|
||||
is( keys %{$linker->{cache}},7, "Ninth (matching) term not added to cache because thesaurus differs but is not considered");
|
||||
|
||||
$linker->get_link($subject_heading9);
|
||||
is( keys %{$linker->{cache}},7, "Tenth (matching) term not added to cache because thesaurus differs but is not considered");
|
||||
|
||||
t::lib::Mocks::mock_preference('LinkerConsiderThesaurus',1);
|
||||
|
||||
$linker->update_cache($subject_heading,32);
|
||||
is( $linker->{cache}->{$subject_heading->search_form.$subject_heading->auth_type.$subject_heading->{'thesaurus'}}->{authid}, 32, "Linker cache is correctly updated by 'update_cache'");
|
||||
my ( $authid, undef ) = $linker->get_link($subject_heading);
|
||||
|
|
|
|||
Loading…
Reference in New Issue