Bug 35125: Respect LinkerConsiderThesaurus in update_cache

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>
This commit is contained in:
Nick Clemens 2024-06-25 14:56:04 +00:00 committed by Katrin Fischer
parent 1894fc5101
commit 8b691a2b9c
Signed by: kfischer
GPG key ID: 0EF6E2C03357A834
2 changed files with 9 additions and 1 deletions

View file

@ -92,6 +92,7 @@ sub update_cache {
my $search_form = $heading->search_form(); my $search_form = $heading->search_form();
my $auth_type = $heading->auth_type(); my $auth_type = $heading->auth_type();
my $thesaurus = $heading->{thesaurus} || 'notdefined'; my $thesaurus = $heading->{thesaurus} || 'notdefined';
$thesaurus = 'notconsidered' unless C4::Context->preference('LinkerConsiderThesaurus');
my $fuzzy = 0; my $fuzzy = 0;
$self->{'cache'}->{$search_form.$auth_type.$thesaurus}->{'cached'} = 1; $self->{'cache'}->{$search_form.$auth_type.$thesaurus}->{'cached'} = 1;

View file

@ -42,7 +42,7 @@ my $schema = $builder->schema();
$schema->storage->txn_begin; $schema->storage->txn_begin;
subtest 'Test caching in get_link and update_cache' => sub { subtest 'Test caching in get_link and update_cache' => sub {
plan tests => 16; plan tests => 18;
my @tags = C4::Context->preference('marcflavour') eq 'UNIMARC' ? (601,'j',602,'a') : (650,'a',655,'a'); my @tags = C4::Context->preference('marcflavour') eq 'UNIMARC' ? (601,'j',602,'a') : (650,'a',655,'a');
@ -120,6 +120,13 @@ subtest 'Test caching in get_link and update_cache' => sub {
is( $authid, 4, "Correct id for sao term is retrieved from the cache" ); is( $authid, 4, "Correct id for sao term is retrieved from the cache" );
$linker->update_cache($subject_heading4,78); $linker->update_cache($subject_heading4,78);
is( $linker->{cache}->{$subject_heading4->search_form.$subject_heading4->auth_type.$subject_heading4->{'thesaurus'}}->{authid}, 78, "Linker cache for the bnb record is correctly updated by 'update_cache'"); is( $linker->{cache}->{$subject_heading4->search_form.$subject_heading4->auth_type.$subject_heading4->{'thesaurus'}}->{authid}, 78, "Linker cache for the bnb record is correctly updated by 'update_cache'");
t::lib::Mocks::mock_preference('LinkerConsiderThesaurus',0);
$linker->update_cache($subject_heading,32);
is( $linker->{cache}->{$subject_heading->search_form.$subject_heading->auth_type.'notconsidered'}->{authid}, 32, "Linker cache is correctly updated by 'update_cache'");
( $authid, undef ) = $linker->get_link($subject_heading);
is( $authid, 32, "Correct id is retrieved from the cache" );
}; };
$schema->storage->txn_rollback; $schema->storage->txn_rollback;