View | Details | Raw Unified | Return to bug 26393
Collapse All | Expand All

(-)a/Koha/CirculationRules.pm (+16 lines)
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
(-)a/admin/smart-rules.pl (-1 / +1 lines)
Lines 69-74 my $language = C4::Languages::getlanguage(); Link Here
69
69
70
my $cache = Koha::Caches->get_instance;
70
my $cache = Koha::Caches->get_instance;
71
$cache->clear_from_cache( Koha::CirculationRules::GUESSED_ITEMTYPES_KEY );
71
$cache->clear_from_cache( Koha::CirculationRules::GUESSED_ITEMTYPES_KEY );
72
$cache->clear_from_cache( Koha::CirculationRules::EFFECTIVE_RULE_KEY );
72
73
73
if ($op eq 'delete') {
74
if ($op eq 'delete') {
74
    my $itemtype     = $input->param('itemtype');
75
    my $itemtype     = $input->param('itemtype');
75
- 

Return to bug 26393