|
Lines 26-31
use Koha::CirculationRule;
Link Here
|
| 26 |
use base qw(Koha::Objects); |
26 |
use base qw(Koha::Objects); |
| 27 |
|
27 |
|
| 28 |
use constant GUESSED_ITEMTYPES_KEY => 'Koha_IssuingRules_last_guess'; |
28 |
use constant GUESSED_ITEMTYPES_KEY => 'Koha_IssuingRules_last_guess'; |
|
|
29 |
use constant EFFECTIVE_RULE_KEY => 'Koha_CirculationRule_get_effective_rule-'; |
| 30 |
use constant CACHE_NO_CIRCULATION_RULE_VALUE => 'NONE'; |
| 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 |
if ( ref $cached eq 'SCALAR' && $cached eq CACHE_NO_CIRCULATION_RULE_VALUE ) { |
| 203 |
return undef; |
| 204 |
} |
| 205 |
my $cr = Koha::CirculationRule->new($cached); |
| 206 |
$cr->{_result}->in_storage(1); # Tell it exists in DB |
| 207 |
return $cr; |
| 208 |
} |
| 209 |
|
| 193 |
for my $v ( $branchcode, $categorycode, $itemtype ) { |
210 |
for my $v ( $branchcode, $categorycode, $itemtype ) { |
| 194 |
$v = undef if $v and $v eq '*'; |
211 |
$v = undef if $v and $v eq '*'; |
| 195 |
} |
212 |
} |
|
Lines 212-217
sub get_effective_rule {
Link Here
|
| 212 |
} |
229 |
} |
| 213 |
)->single; |
230 |
)->single; |
| 214 |
|
231 |
|
|
|
232 |
$cache->set_in_cache( $cache_key, $rule ? $rule->unblessed : CACHE_NO_CIRCULATION_RULE_VALUE ); |
| 233 |
|
| 215 |
return $rule; |
234 |
return $rule; |
| 216 |
} |
235 |
} |
| 217 |
|
236 |
|