From c61e3e9d11a69c1ec89b7cfcde40b72324815876 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Tue, 25 Jun 2024 14:56:04 +0000 Subject: [PATCH] Bug 35125: Respect LinkerConsiderThesaurus in update_cache Signed-off-by: Phil Ringnalda Signed-off-by: Martin Renvoize Signed-off-by: Katrin Fischer (cherry picked from commit 8b691a2b9c512f1ff2e17f471b2afec61f46cbfb) Signed-off-by: Lucas Gass --- C4/Linker/Default.pm | 1 + t/db_dependent/Linker_Default.t | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/C4/Linker/Default.pm b/C4/Linker/Default.pm index d34e916610..9b3f225bce 100644 --- a/C4/Linker/Default.pm +++ b/C4/Linker/Default.pm @@ -92,6 +92,7 @@ sub update_cache { 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 $fuzzy = 0; $self->{'cache'}->{$search_form.$auth_type.$thesaurus}->{'cached'} = 1; diff --git a/t/db_dependent/Linker_Default.t b/t/db_dependent/Linker_Default.t index d08e33e932..9a878da8dc 100755 --- a/t/db_dependent/Linker_Default.t +++ b/t/db_dependent/Linker_Default.t @@ -42,7 +42,7 @@ my $schema = $builder->schema(); $schema->storage->txn_begin; 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'); @@ -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" ); $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'"); + + 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; -- 2.39.5