Lines 21-31
use Modern::Perl;
Link Here
|
21 |
use Carp qw(croak); |
21 |
use Carp qw(croak); |
22 |
|
22 |
|
23 |
use Koha::Exceptions; |
23 |
use Koha::Exceptions; |
|
|
24 |
use Koha::Caches; |
24 |
use Koha::CirculationRule; |
25 |
use Koha::CirculationRule; |
25 |
|
26 |
|
26 |
use base qw(Koha::Objects); |
27 |
use base qw(Koha::Objects); |
27 |
|
28 |
|
28 |
use constant GUESSED_ITEMTYPES_KEY => 'Koha_IssuingRules_last_guess'; |
29 |
use constant GUESSED_ITEMTYPES_KEY => 'Koha_IssuingRules_last_guess'; |
|
|
30 |
use constant EFFECTIVE_RULE_KEY => 'Koha_CirculationRule_get_effective_rule-'; |
29 |
|
31 |
|
30 |
=head1 NAME |
32 |
=head1 NAME |
31 |
|
33 |
|
Lines 190-195
sub get_effective_rule {
Link Here
|
190 |
"Required parameter 'rule_name' missing") |
192 |
"Required parameter 'rule_name' missing") |
191 |
unless $rule_name; |
193 |
unless $rule_name; |
192 |
|
194 |
|
|
|
195 |
my $cache = Koha::Caches->get_instance(); |
196 |
my $cache_key = EFFECTIVE_RULE_KEY.$rule_name; |
197 |
foreach ( $branchcode, $categorycode, $itemtype ) { |
198 |
$cache_key .= '-'.($_ ? $_ : ''); |
199 |
} |
200 |
my $cached = $cache->get_from_cache($cache_key); |
201 |
if ($cached) { |
202 |
my $cr = Koha::CirculationRule->new($cached); |
203 |
$cr->{_result}->in_storage(1); # Tell it exists in DB |
204 |
return $cr; |
205 |
} |
206 |
|
193 |
for my $v ( $branchcode, $categorycode, $itemtype ) { |
207 |
for my $v ( $branchcode, $categorycode, $itemtype ) { |
194 |
$v = undef if $v and $v eq '*'; |
208 |
$v = undef if $v and $v eq '*'; |
195 |
} |
209 |
} |
Lines 212-217
sub get_effective_rule {
Link Here
|
212 |
} |
226 |
} |
213 |
)->single; |
227 |
)->single; |
214 |
|
228 |
|
|
|
229 |
$cache->set_in_cache( $cache_key, $rule->unblessed ) if $rule; |
230 |
|
215 |
return $rule; |
231 |
return $rule; |
216 |
} |
232 |
} |
217 |
|
233 |
|