@@ -, +, @@ $cached_indicators --- Koha/Authority/ControlledIndicators.pm | 22 ++++------------------ t/Koha/Authority/ControlledIndicators.t | 20 +------------------- 2 files changed, 5 insertions(+), 37 deletions(-) --- a/Koha/Authority/ControlledIndicators.pm +++ a/Koha/Authority/ControlledIndicators.pm @@ -20,8 +20,6 @@ package Koha::Authority::ControlledIndicators; use Modern::Perl; use C4::Context; -our $cached_indicators; - =head1 NAME Koha::Authority::ControlledIndicators - Obtain biblio indicators, controlled by authority record @@ -39,7 +37,6 @@ Koha::Authority::ControlledIndicators - Obtain biblio indicators, controlled by sub new { my ( $class, $params ) = @_; $params = {} if ref($params) ne 'HASH'; - $cached_indicators = undef; return bless $params, $class; } @@ -66,11 +63,11 @@ sub get { $flavour = uc($flavour); $flavour = 'UNIMARC' if $flavour eq 'UNIMARCAUTH'; - $cached_indicators //= _load_pref(); + $self->{_parsed} //= _load_pref(); my $result = {}; - return $result if !exists $cached_indicators->{$flavour}; - my $rule = $cached_indicators->{$flavour}->{$tag} // - $cached_indicators->{$flavour}->{'*'} // + return $result if !exists $self->{_parsed}->{$flavour}; + my $rule = $self->{_parsed}->{$flavour}->{$tag} // + $self->{_parsed}->{$flavour}->{'*'} // {}; my $report_fld = $record ? $record->field( $report_tag ) : undef; @@ -146,17 +143,6 @@ sub _thesaurus_info { return ( $ind, $sub2 ); } -=head3 clear - - Clear internal cache. - -=cut - -sub clear { - my ( $self, $params ) = @_; - $cached_indicators = undef; -} - =head1 AUTHOR Marcel de Rooy, Rijksmuseum Amsterdam, The Netherlands --- a/t/Koha/Authority/ControlledIndicators.t +++ a/t/Koha/Authority/ControlledIndicators.t @@ -10,7 +10,7 @@ use t::lib::Mocks; use Koha::Authority::ControlledIndicators; subtest "Simple tests" => sub { - plan tests => 10; + plan tests => 8; t::lib::Mocks::mock_preference('AuthorityControlledIndicators', q| marc21,600,ind1:auth1,ind2:x @@ -52,24 +52,6 @@ marc21,800,ind1:, }); is( $res->{ind1}, '', 'ind1: clears 1st indicator' ); is( exists $res->{ind2}, '', 'Check if 2nd indicator key does not exist' ); - - # Test caching - t::lib::Mocks::mock_preference('AuthorityControlledIndicators', q{} ); - $res = $oInd->get({ - flavour => "MARC21", - report_tag => '100', - auth_record => $record, - biblio_tag => '700', - }); - is( $res->{ind1}, '4', 'Cache not cleared yet' ); - $oInd->clear; - $res = $oInd->get({ - flavour => "MARC21", - report_tag => '100', - auth_record => $record, - biblio_tag => '700', - }); - is_deeply( $res, {}, 'Cache cleared' ); }; subtest "Tests for sub _thesaurus_info" => sub { --